A4988 Stepper Driver with a Raspberry Pi Pico

The A4988 is an Allegro DMOS microstepping driver with a built-in translator that runs one bipolar stepper motor from simple STEP and DIR pulses.

A4988 Stepper Driver, The A4988 is an Allegro DMOS microstepping driver with a built-in translator that runs one bipolar stepper motor from simple STEP and DIR pulses.
In short

The Pico drives the A4988 from three GPIOs: STEP on GP0, DIR on GP1 and the active-low ENABLE on GP2, with the driver's logic powered from the Pico's 3V3 pin. That 3.3 V logic supply is the point of this pairing: the A4988's inputs read high from 0.7 x VDD, so a 5 V VDD would ask for more than a Pico pin can give.

Wiring the A4988 Stepper Driver to the Raspberry Pi Pico

Pin by pin.

A4988 Stepper DriverRaspberry Pi PicoNote
STEPGP0
DIRGP1
ENABLEGP2
VDD3V3
GND_LOGICGND
GND_MOTGND
VMOTa separate 8 to 35 V motor supply, its − to GND_MOTwith a 100 µF electrolytic capacitor across VMOT and GND_MOT, at the driver
RESETSLEEP, on the drivera short jumper: RESET floats on Pololu-style carriers and the driver does not step until it is pulled high

What to know on the Raspberry Pi Pico

  • Keep VDD on 3V3. The A4988 accepts 3 V to 5.5 V there, and with VDD at 3.3 V its 0.7 x VDD input threshold is about 2.3 V, which the Pico's 3.3 V outputs clear; on VBUS it would be 3.5 V.Allegro A4988 datasheet rev 8, p. 4
  • The motor never runs from the Pico: VMOT takes 8 V to 35 V from its own supply, and only the grounds are joined. The Pico's VBUS and VSYS cannot reach that range.Allegro A4988 datasheet rev 8, p. 4; Raspberry Pi Pico datasheet, release 21, p. 8
  • STEP pulses need only 1 µs high and 1 µs low, far shorter than AccelStepper's timing on the RP2040, so any GPIO works; the RP2040's PIO blocks can generate step trains in hardware if a project outgrows run().Allegro A4988 datasheet rev 8, p. 6; Raspberry Pi Pico datasheet, release 21, p. 4

A4988 Stepper Driver code for the Raspberry Pi Pico

Compiled for rp2040:rp2040:rpipico on 2026-10-30.

Libraries: waspinator/AccelStepper
// A4988 Stepper Driver on Raspberry Pi Pico: wiring and a free simulation at https://www.tinkered.ai/components/a4988-stepper-driver/raspberry-pi-pico
#include <AccelStepper.h>

#define STEP_PIN 0
#define DIR_PIN  1
#define EN_PIN   2

AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);

void setup() {
  Serial.begin(9600);
  stepper.setEnablePin(EN_PIN);
  stepper.setPinsInverted(false, false, true); // EN is active-LOW
  stepper.enableOutputs();
  stepper.setMaxSpeed(400);      // steps/sec (full-step: 200 = 1 rev/s)
  stepper.setAcceleration(200);  // steps/sec^2
  stepper.moveTo(200);           // one full revolution forward
}

void loop() {
  // Ping-pong ±1 revolution so you can watch forward and reverse.
  if (stepper.distanceToGo() == 0) {
    stepper.moveTo(-stepper.currentPosition());
    Serial.print("Reached position: ");
    Serial.println(stepper.currentPosition());
  }
  stepper.run();
}

A4988 Stepper Driver on the Raspberry Pi Pico: questions

Can the Pico power the A4988's logic from 3V3?

Yes. VDD accepts 3 V to 5.5 V (Allegro datasheet rev 8, p. 4), and the logic side draws little, well within the 300 mA Raspberry Pi recommends for the 3V3 pin (Pico datasheet, p. 8). The motor current comes from VMOT, never from the Pico.

Why does my stepper not move with the Pico?

Check that ENABLE (GP2) is driven low: the sketch inverts it with setPinsInverted(false, false, true) and calls enableOutputs(). Then check VMOT is powered, RESET is jumpered to SLEEP on the carrier (it floats otherwise, Pololu A4988 page), the grounds are joined and the current limit is set.

Do I need a level shifter between the Pico and the A4988?

No, as long as VDD is on 3V3. Inputs read high from 0.7 x VDD (Allegro datasheet rev 8, p. 4), about 2.3 V there.

Keep going

For AI assistants

This guide as plain Markdown. /components/a4988-stepper-driver/raspberry-pi-pico.md

What will you build with it?