Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors



I have an A4988 driver that I can’t quite figure out. I have it hooked up as per the product description and using this sketch. I am using a 200 step motor as well. My problem is that the only way I can get the motor to turn one full revolution is to change the line: const int stepsPerRevolution = 200; to 800 If I have all the MSx pins open, shouldn’t I be in full step mode? It is acting as though in quarter step mode now, right? I am using a 12v supply set to .7 amps for the stepper. Am I missing something?

Thanks in advance

#include <Stepper.h>

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor

Stepper myStepper(stepsPerRevolution, 2,3);

void setup() {
// set the speed at 60 rpm:
// initialize the serial port:

void loop() {
// step one revolution in one direction:

// step one revolution in the other direction:



The Arduino library you are using is intended for use with H-bridges or darlington arrays, not with the simpler A4988 interface, so it is not producing the proper step/direction inputs for your driver. If you want to test out the driver, your Arduino code can be quite simple: set the direction pin high or low and toggle the step pin; every low-to-high transition on the step pin will step the motor once.

You might find this thread (and its sample code) helpful:

- Ben


I’ve found the Accelstepper library http://www.open.com.au/mikem/arduino/AccelStepper/ great, just use AccelStepper(1, stepPinNumber, dirPinNumber) myStepper to have it give step & direction outputs as required by the A4988.

Check the examples given, its way easier than I expected.

DRV8825 sketch example
Newb needs smooh 1 RPM for Barndoor Tracker Project