EZ Stepper Code

So some students were wondering how to get the Sparkfun Easy stepper driver working. I pointed them to some Bildr code (http://bildr.org/2011/06/easydriver/). After testing it, while the wiring was a good start, the code did not work optimally.

Therefore I made some simple code that seems to get the Easy Stepper Driver saying “Hello World”:

/*This code controls a stepper motor with the
EasyDriver board for 1 step
int dirPin = 2;
int stepPin = 3;

void setup()
pinMode(dirPin, OUTPUT);
pinMode(stepPin, OUTPUT);
void loop()
digitalWrite(dirPin, LOW); // Set the direction.

digitalWrite(stepPin, LOW); // This LOW to HIGH change is what creates the
digitalWrite(stepPin, HIGH); // “Rising Edge” so the easydriver knows to when to step.
delayMicroseconds(500); // This delay time is close to top speed for this
// particular motor. Any faster the motor stalls.
//End code

If you change the dirPin to HIGH, this changes the direction of the stepper motor. What happens if you try it with a “For” Loop?