Allegro A4988 and Arduino (3)

In the last part of my tutorial about the A4988 driver, I’m going to explain how to build a controller to adjust speed and rotation direction of a stepper motor.


I used the same setup introduced in a previous post:

  • an Arduino Uno;
  • a LCD Keypad shield;
  • a Pololu A4988 driver mounted on a breadboard;
  • a NEMA17 stepper motor.

Allegro A4988 and Arduino (3)


Using the controller, you can adjust the speed (from 0 to 70 RPM, revolutions per minute) and the rotation direction.
On the LCD are displayed the actual speed, direction and a progress bar:
The 5 available buttons are used to control the motor:

  • UP and DOWN adjust the speed;
  • LEFT and RIGHT adjust the direction;
  • SELECT activates the emergency stop (speed = 0).

Continuous rotation

To achieve a continuous rotation, your sketch must send the step commands to the Pololu driver at constant frequency.
Let’s see an example: for a speed of 60RPM and for a motor with 200 steps / revolution, Arduino must send to the driver (60*200)/60 = 200 commands / sec or a command every 5ms.
To ensure an accurate timing, I’m going to use the interrupts generated by the Timer1 as explained in this article.
From the Playground you can download a convenient library to configure that Timer:

For more detail:  Allegro A4988 and Arduino (3)

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top