changing the value in delay() . It is currently set to 1 microsecond, making
each step pulse take 2 microseconds. Increasing the delay will slow down
the motor, while decreasing the delay will speed up the motor.
//Reverse default microstep mode function
void ReverseStepDefault()
{
Serial.println("Moving in reverse at default step mode.");
digitalWrite(dir, HIGH); //Pull direction pin high to move i
n "reverse"
for(x= 1; x<1000; x++) //Loop the stepping enough times fo
r motion to be visible
{
digitalWrite(stp,HIGH); //Trigger one step
delay(1);
digitalWrite(stp,LOW); //Pull step pin low so it can be tr
iggered again
delay(1);
}
Serial.println("Enter new option");
Serial.println();
}
The third function shows off the different microstepping functionality that the
Big Easy Driver provides. To enable the motor to step in 1/16th microsteps,
we must set MS1, MS2, and MS3 HIGH. This sets the logic of the board to
1/16th microstep mode. If you want to have the motor step at a different
microstep mode, change the settings for one of the MS# pins. Check the
truth table in the Hardware Overview section, if you need a reminder of
what settings are enabled by the various pin states.
// 1/16th microstep foward mode function
void SmallStepMode()
{
Serial.println("Stepping at 1/16th microstep mode.");
digitalWrite(dir, LOW); //Pull direction pin low to move "fo
rward"
digitalWrite(MS1, HIGH); //Pull MS1,MS2, and MS3 high to se
t logic to 1/16th microstep resolution
digitalWrite(MS2, HIGH);
digitalWrite(MS3, HIGH);
for(x= 1; x<1000; x++) //Loop the forward stepping enough t
imes for motion to be visible
{
digitalWrite(stp,HIGH); //Trigger one step forward
delay(1);
digitalWrite(stp,LOW); //Pull step pin low so it can be tr
iggered again
delay(1);
}
Serial.println("Enter new option");
Serial.println();
}
The final motor function available shows how the motor can change
direction on the fly. The function works just as the forward and reverse
functions above, but switches between states quickly. This example will
step the motor 1000 steps forward and then reverse 1000 steps. This
allows you to precisely move something with the motor in one direction, and
return to the starting position exactly. Precise position control is a great
benefit of stepper motors!
Page 8 of 9