Subscribe to Arduino Academy and start learning today for FREE!

Stepper Motor Controller – Part 2

Continuing our saga from Part 1, We finished soldering up the controller shield with all the components. We have downloaded the library, and have connected the stepper motor. The motor has 4 wires, which we have attached to the M1/M2 connector. The wires connect top to bottom:

Become the Maker you were born to be. Try Arduino Academy for FREE!


1. Orange
2. Yellow
3. N/C
4. Green
5. Brown

A 12v power supply connects to the motor external power connector. Make sure you do not enable the Arduino power jumper just to the right of the motor external power connector.

Video can be seen at

Discuss this project at


#include <AFMotor.h>

AF_Stepper motor(48, 1);

void setup() {

motor.setSpeed(10); // 10 rpm

motor.step(100, FORWARD, SINGLE);

void loop() {
motor.step(100, FORWARD, SINGLE);
motor.step(100, BACKWARD, SINGLE);

motor.step(100, FORWARD, DOUBLE);
motor.step(100, BACKWARD, DOUBLE);

motor.step(100, FORWARD, INTERLEAVE);
motor.step(100, BACKWARD, INTERLEAVE);

motor.step(100, FORWARD, MICROSTEP);
motor.step(100, BACKWARD, MICROSTEP);

Become the Maker you were born to be. Try Arduino Academy for FREE!

Learn more by reading:
Arduino Internals, by Dale Wheat

Notify of
Inline Feedbacks
View all comments


Would love your thoughts, please comment.x