Stepper Motor Usage

In this example we'll wire up and use a bi-polar stepper motor with recommended 9V motor voltage, and 200 steps per rotation.


We'll wire it to a Metro, but you can use any microcontroller you like!


  • Vmotor to 9V (red wire)
  • GND to ground
  • SLP to > 2.7V power pin
  • AIN2 to Digital 4
  • AIN1 to Digital 5
  • BIN1 to Digital 6
  • BIN2 to Digital 7

Then hook one stepper motor coil to Motor A (red and yellow) and the second coil to Motor B (green and gray/brown). If you have another motor, you'll need to experiment a little to figure out which wires are which coil. Check any documentation you have! You can use a multimeter to measure between wires, the ones with a small resistance between them are a pair to a coil, for example. If the motor is vibrating but not spinning, check all wires are connected and try flipping around a pair or rechecking the wire pairs.

If you have a unipolar motor, there will be a 5th or 6th wire that is the 'common' wire. Connect these wires to the GND pins in between the Motor A and B outputs on the breakout.


We'll use the built-in Arduino Stepper library, but you can manually toggle the AIN1/AIN2/BIN1/BIN2 pins with your own favorite microcontroller setup

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 200

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 4, 5, 6, 7);

void setup()
  Serial.println("Stepper test!");
  // set the speed of the motor to 30 RPMs

void loop()

Basically after you make the Stepper object with the 4 control pins, you can set the rotational speed (in RPM) with setSpeed(rpm) and then step forward or backwards with .step(steps) where steps is positive for 'forward' and negative for 'backward'

For more details, check out the Stepper library

Last updated on 2016-10-26 at 06.17.19 PM Published on 2016-10-26 at 06.14.31 PM