How To Drive A Bi-directional Stepper Motor

About the project

How to drive a Nema17 bi-directional stepper motor with arduino uno, an a4988 driver, a potentiometer and two buttons

Project info

Difficulty: Easy

Platforms: Arduino

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

Male to Male Jumpers Male to Male Jumpers x 27
Male to Female Jumpers Male to Female Jumpers x 3
A4988 Stepper Motor Driver A4988 Stepper Motor Driver x 1
Arduino Uno R3 ATmega328 with USB cable Arduino Uno R3 ATmega328 with USB cable x 1
AC/DC Adapter 12V - 2A AC/DC Adapter 12V - 2A x 1
2.1mm jack to screw terminal block 2.1mm jack to screw terminal block x 1
10 Ohm resistors 10 Ohm resistors x 2
100 Ohm resistors 100 Ohm resistors You can also use 2 X 220 Ohm resistors x 6
Push buttons Push buttons x 2
100uF 16V Electrolytic Capacitors - Pack of 10 100uF 16V Electrolytic Capacitors - Pack of 10 x 1
Leds Leds x 2
Nema 17 Stepper Motor Nema 17 Stepper Motor x 1
10K Ohm Potentiometer 10K Ohm Potentiometer x 1
Breadboard - Classic Breadboard - Classic x 1

View all

Hand tools and fabrication machines

Small Screwdriver Small Screwdriver x 1



In this tutorial, we demonstrate how to program an Arduino Uno R3 Board with a simple code and wiring in order to run a Bi - Directional Nema 17 Stepper Motor driven by an A4988 or DRV8825 driver with two push buttons and a potentiometer to regulate the speed of the rotation.


The functioning of this mechanism is really easy and intuitive. After following the tutorial step by step take your time and enjoy the result of your work. As we said we will use two different colours buttons: - A blue button to start the rotation - A red button to invert the rotation's direction.

So, push the blue button and keep it pressed to start the rotation, if you want to stop the rotation just release it. Now push the red button one time to invert the direction and after you've done that, push the blue botton and keep it pressed to run the engine.

You can alternate the rotation from clockwise to counterclockwise with a click. While you are pressing the blu button you can smoothly increase or decrease the speed of the spinning turning the potentiometer's handle to the left or to the right.

When you release the potentiometer's handle, the speed will be constant in both sense until you release the blue button.

Click also here to WATCH FULL TUOTORIAL VIDEO and read the entire description with direct link to CODE.

Schematics, diagrams and documents

Fritzing Wiring Project


Photo of NProduction




Leave your feedback...