Skip to main content

wokwi-a4988 Reference

A4988 Stepper Motor driver, for use with wokwi-stepper-motor

Wokwi A4988

Pin names

NameDescriptionDefault *
ENABLEEnable pin, active low (pulled down)Low (0)
MS1Microstep select pin 1Low (0)
MS2Microstep select pin 2Low (0)
MS3Microstep select pin 3Low (0)
RESETReset pin, active low (floating)
SLEEPSleep pin, active low (pulled up)High (1)
STEPStep input, connect to microcontroller
DIRDirection input: 0=counterclockwise, 1=clockwise
VDDLogic power supply
1BConnect to motor's B-
1AConnect to motor's B+
2AConnect to motor's A+
2BConnect to motor's A-
VMOTMotor power supply, not used in the simulation

* Digital pins with a default value of Low (0) are pulled-down, and pins with a default value of High (1) are pulled up. Pins without a default value are floating.

Microstepping configuration

Standard stepper motors have 200 steps per revolution (the steps are spaces 1.8 degrees apart). The stepper driver supports microstepping: turning the motor less than one step for every pulse. Microstepping allows finer control of the motor movement.

Use the MS1/MS2/MS3 pins to select the microstepping configuration for the stepper driver:

MS1MS2MS3Operation modeDegreesMicrosteps/revolution
000Full step (default)1.8200
100Half step0.9400
0101/4 step*0.45800
1101/8 step*0.2251600
1111/16 step*0.11253200

* These mode are not fully supported by wokwi-stepper-motor. When using these modes, the number of steps per revolution will still be correct, but the motor angle will only update every half step. For instance, if you use 1/8 step mode, the motor will move half a step (0.9 degrees) every four STEP pin pulses.

Using the A4988 Stepper Driver

Connect the stepper motor pins to the 1B/1A/2A/2B pins of the driver. The RESET pin has to be HIGH, so you can connect it to the adjacent SLEEP pin (which is pulled HIGH by default). Alternatively, you can enable/disable the stepper motor driver from your code by connecting the RESET/SLEEP pins to your microcontroller.

Use the STEP pin to move the stepper motor. Every HIGH pulse on this pin will move the motor one step (or microstep, depending on the MS1/MS2/MS3 pins). When the DIR pin is HIGH, the stepper motor will move clockwise. When the DIR pin is LOW, the motor will move counterclockwise.

For example, if DIR, MS1 and MS3 are LOW, and MS2 is HIGH (1/4 step mode), then pulsing the STEP pin will move the motor 1/4 step (0.45 degrees) counterclockwise.

Simulator Examples