StepperDriver

Arduino library for A4988, DRV8825, DRV8834, DRV8880 and generic two-pin (DIR/STEP) stepper motor drivers

View the Project on GitHub

arduino-library-badge Actions Status Actions Status

StepperDriver

A4988, DRV8825, DRV8834, DRV8880 and generic two-pin stepper motor driver library. Features:

Hardware currently supported:

Microstepping

The library can set microstepping and generate the signals for each of the support driver boards.

High RPM plus high microstep combinations may not work correctly on slower MCUs, there is a maximum speed achieveable for each board, especially with acceleration on multiple motors at the same time.

Motors

Connections

Minimal configuration from Pololu DRV8834 page:

Wiring

This is suggested wiring for running the examples unmodified. All the pins below can be changed.

Set Max Current

The max current is set via the potentiometer on board. Turn it while measuring voltage at the passthrough next to it. The formula is V = I5R where I=max current, R=current sense resistor installed onboard

For latest info, see the Pololu board information pages.

Code

See the BasicStepperDriver example for a generic driver that should work with any board supporting the DIR/STEP indexing mode.

The Microstepping example works with a DRV8834 board.

For example, to show what is possible, here is the ClockStepper example that moves a stepper motor like the seconds hand of a watch:

#include <Arduino.h>
#include "A4988.h"

// using a 200-step motor (most common)
#define MOTOR_STEPS 200
// configure the pins connected
#define DIR 8
#define STEP 9
#define MS1 10
#define MS2 11
#define MS3 12
A4988 stepper(MOTOR_STEPS, DIR, STEP, MS1, MS2, MS3);

void setup() {
    // Set target motor RPM to 1RPM and microstepping to 1 (full step mode)
    stepper.begin(1, 1);
}

void loop() {
    // Tell motor to rotate 360 degrees. That's it.
    stepper.rotate(360);
}

Hardware