[Stepper motor controller]

Stepper Motors: Lady Ada Motor Shield

A stepper motor is a motor that moves one tiny step at a time. So you can control exactly how far it rotates in either direction by telling it how many steps to move.

Like all motors, a stepper requires a separate battery -- you can't power it directly off the Arduino. We have the Lady Ada motor shield, which makes it easier to wire up the battery pack.

We'll try to have shields pre-wired for you, but in case the wires come apart, the 4 wires from the stepper motor get wired to the M3 and M4 terminals like this. You'll need a small screwdriver for the wire terminals.

Wire color black green blue red
Ada shield M3 0 M3 1 M4 0 M4 1

Then take the connector for the battery pack and wire the red wire to the terminal labeled +M, and the black wire to GND.

Programming a stepper

Use the AFMotor library: you can download it from GitHub, or we'll have it on a USB stick at the workshop.

Once it's installed, you can use the example in File->examples->AFMotor->StepperTest (you may have to restart the Arduino software to see it).

Or use this sample code that's simpler than the example in the menu:


AF_Stepper motor(48, 2);

void setup() {
  motor.setSpeed(100);  // 10 rpm   


void loop() {
  motor.step(500, FORWARD, SINGLE);    // Go 500 steps forward
  motor.step(100, BACKWARD, SINGLE);   // Go 100 steps back
  delay(1000);                         // Pause for a second