Stepper Motor Control: Details
Stepper Motor Control: Details
Details :
int steppin
int dirpin
void setup
: The void keyword is used only in function declarations. It indicates that
the function is expected to return no information to the function from which it was called.
pinMode(stepPin,OUTPUT)
pinMode(dirPin,OUTPUT)
void loop : After creating a setup() function, which initializes and sets the initial values,
the loop() function does precisely what its name suggests, and loops consecutively,
allowing your program to change and respond. Use it to actively control the Arduino
board.
Digitalwrite : Write a HIGH or a LOW value to a digital pin.If the pin has been configured
as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or
3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.if the pin is configured as an
INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pullup on the input
pin. It is recommended to set the pinMode() to INPUT PULLUP to enable the internal
pull-up resistor
digitalWrite(dirPin,HIGH) : Enables the motor to move in a particular direction
for(int x = 0; x < 200; x++) : by for loop condition motor will take full cycle rotation
as the driver is set in a full step mode and stepper motor is taking 200 steps (1.8 degree
angle) so that we have to sent 200 pulses to make full cyle rotation so for loop have 200
iterations and each tiome step pin is made high (digitalWrite(stepPin,HIGH))
digitalWrite(dirPin,LOW);
then make 2 full cyle rotation by the loop of 400 iteration : for(int x = 0; x < 400; x++)