ESP32 C3 Super Mini - Stepper Motor A4988 Driver
In December, people stop in front of the toy shop. A small lift goes up and down in the window, and its cabin always stops level with the floor. How does it know where to stop? It counts. The shaft of a stepper motor goes round in little steps of the same size, so "one floor up" is nothing more than a number. On this page, the ESP32 C3 Super Mini keeps count. It fits under the roof of a model house, yet its pins have no strength for a motor. So it only gives orders. A DIYables A4988 module takes them and feeds the coils of a NEMA 17. You begin with one turn up and one turn down. At the end, the cabin visits the floors 0, 1, 2 and 3, and it starts and brakes as gently as a real lift.
In this tutorial, you'll learn:
- Why a NEMA 17 has four wires, and how 200 small steps become one turn
- Which of the 16 A4988 pins a lift really needs
- Why 3.3 is the right pin for V or VDD, and why 5V is forbidden there
- How three tiny switches and one trimmer prepare the driver for the first ride
- Where each wire goes, from the C3 on its breadboard to the driver
- How to move the motor with digitalWrite() alone, and how the AccelStepper library drives from floor to floor

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
You may skip the expansion board, as it is optional. The bare module then wants a 100uF capacitor (35V or higher is best) and the wires of the second drawing. For the lift itself, you need a light paper cabin, a thread and a small spool for the motor shaft. There is no hurry with these parts. Both sketches also work with a bare shaft and a paper arrow.
Overview of NEMA 17 Stepper Motor
Two coils of copper wire hide in a NEMA 17, and they do not touch each other. This is what "bipolar" stands for on this page. Both ends of both coils come out of the motor. So you see four wires, and they belong together two by two. The driver has two pins for each of these pairs.
Motors with six wires are welcome too, but only four of the wires are used. A motor with five wires, like the small 28BYJ-48, needs a different driver: ESP32 C3 Super Mini - 28BYJ-48 Stepper Motor ULN2003 Driver.
Count 200 full steps, and the shaft has gone around once, because each of them is worth 1.8 degrees. With a spool on the shaft, steps turn into centimeters.
Our Lift in Numbers:
- Spool: 19 mm thick, so each turn winds up about 6 cm of thread
- Distance between two floors: 9 cm, which is 1.5 turns or 300 full steps
- Floor 3: 27 cm or 900 full steps above floor 0

| A4988 Pin | Letter | Same Wire Elsewhere | Colour Here |
|---|---|---|---|
| 2B | A | A+, A | black |
| 2A | C | A-, A with a top line | green |
| 1A | B | B+, B | red |
| 1B | D | B-, B with a top line | blue |
"Here" means our own motor. Each factory picks other colours, so believe the datasheet of yours. You have none? Then look for the pairs like this:
- Multimeter, ohm range: touch two wire ends. Only a few ohms on the display? Same coil
- Only your fingers: the motor is not connected to anything. Twist two bare ends together and roll the shaft. Does it brake now? These two come from one coil
Inside a pair, the order is not critical. Swapped, the cabin simply goes down where it should go up. Mixing the pairs is the real fault. Then you hear a growl or see the shaft tremble, and the cabin does not travel.
Overview of A4988 Stepper Motor Driver
Look for a red board that measures just 20 x 15 mm or so. This is the DIYables A4988 module, a board of the StepStick type. The black chip in its center is the A4988 itself. The 2 x 8 male pins are already in place, so nothing is left to solder, and the package has a mini heat sink for the chip. One module runs one bipolar motor. A second lift would need a second module.
How can two thin signal wires move a cabin? DIR says up or down. STEP says "now": the motor goes one step further at every rising edge, the moment when STEP leaves LOW and becomes HIGH. The coils of a stepper must be switched in a fixed pattern. The translator, a unit of the chip, has this pattern built in, so your sketch never thinks about coils. The chip is also a guard. When the coil current has climbed up to the limit, it is switched off for a blink and then on again, over and over. This trick has the name current chopping. It makes 12V harmless even for a motor that is sold as a 3V type.
Key Features:
- Motor side (VMOT): 8V to 35V DC. A 12V adapter is well inside this range
- Logic side (VDD): 3V to 5.5V. With a C3, it has to be 3.3V
- Coil current: about 1A as it comes out of the bag. 2A is the top, and it takes the heat sink plus good cooling
- Five step sizes: full, 1/2, 1/4, 1/8, 1/16
- Control: STEP and DIR, that is all
- Guards in the chip: over-temperature shutdown, under-voltage lockout (the outputs stay off while the supply is too weak) and crossover-current protection
- What it lacks: a FAULT pin, so it cannot report a problem to the C3
Why the A4988 Fits a Model Lift:
- The same number of steps is always the same height, so the sketch finds a floor without any sensor
- The coils keep their holding current at a stop, so the cabin hangs still while the doors are open
- Two GPIO pins do the job, and the other pins of the C3 stay free for buttons, lights or a display
- Driver and C3 together need less space than a box of matches
A4988 Pinout

Left side - signals:
- EN: the on/off switch of the outputs. LOW is on, and the module pulls a free EN to LOW for you. HIGH is off: nobody holds the shaft, and the cabin would sink
- MS1, MS2, MS3: together they choose the step size. Left alone, all three read LOW
- RST: LOW resets the chip. This pin floats, which means that it has no fixed level of its own. That is why RST and SLP get a common wire
- SLP: LOW sends the chip to sleep. A pull-up resistor on the module makes it HIGH, and the common wire shares this HIGH with RST
- STEP: to GPIO7. It wants a full microsecond of HIGH and a full microsecond of LOW, or more
- DIR: to GPIO6. HIGH or LOW chooses up or down
Right side - power and motor:
- VMOT: 12V, from the + of the adapter
- Upper GND: back to the - of the adapter
- 2B, 2A: one pair of motor wires
- 1A, 1B: the second pair
- VDD: to the pin printed 3.3
- Lower GND: to the pin printed G. The two GND pins are one line on the module
The motor pins have two spellings. On the front of the DIYables board you read B2, A2, A1, B1. On its back you read 2B, 2A, 1A, 1B.
Why VDD Gets 3.3V
The A4988 lives on two supplies. VMOT is for the muscles, VDD is for the brain. A DRV8825 would make the second one out of the first, but an A4988 cannot, so VDD must have a wire. The voltage on this wire also draws a line. Only a signal over 0.7 x VDD is a HIGH for the chip:
- With 3.3 on VDD: everything above 2.31V is HIGH. The 3.3V pulses of GPIO7 pass with ease
- With 5V on VDD: HIGH begins at 3.5V. A C3 pin gives 3.3V at best, so a pulse may go unnoticed, and the cabin misses its floor
On the C3, the pins 3.3 and 5V share one row, with only G between them. So look twice where the red wire goes in.
Step Size
In full steps, a light cabin can tremble a bit. The A4988 can cut each step into microsteps, and then the ride becomes smooth and quiet. In return, one floor costs more pulses.
| Step Size | One Turn | One Floor | MS1 | MS2 | MS3 | Switches to Turn ON |
|---|---|---|---|---|---|---|
| full | 200 pulses | 300 pulses | LOW | LOW | LOW | none |
| 1/2 | 400 pulses | 600 pulses | HIGH | LOW | LOW | 3 |
| 1/4 | 800 pulses | 1200 pulses | LOW | HIGH | LOW | 2 |
| 1/8 | 1600 pulses | 2400 pulses | HIGH | HIGH | LOW | 3 and 2 |
| 1/16 | 3200 pulses | 4800 pulses | HIGH | HIGH | HIGH | all |
The last column speaks of the three DIP switches on the expansion board, where ON is HIGH. Count them from the end: the last switch (3) is MS1, the middle one (2) is MS2, the first one (1) is MS3. Without the expansion board, a wire from an MS pin to VDD replaces the ON. The sketch cannot see them, so type the same step size behind MICROSTEPS. If the two disagree, the cabin stops between two floors. For the first ride, leave everything OFF and the number at 1.
Current Limit
Too much current heats the driver, too little makes a weak lift. You choose with the round trimmer. It has no scale, but its voltage, VREF, tells you where you are:
- Any A4988: current limit = VREF / (8 x Rs). Rs is the value of two tiny resistors on the module
- The DIYables module: they are printed R100, 0.1 ohm. This makes VREF = 0.8 x current, so 0.48V is 0.6A, 0.6V is 0.75A and 0.8V is 1A
- Modules with R050: VREF = 0.4 x current
How to Set It:
- Plug only the USB cable into the C3. VDD has its 3.3V now, and the 12V adapter has no part in this
- Multimeter in the DC volt range: black probe to G, red probe to the metal face of the trimmer
- Take a small screwdriver, turn by a hair, read the display. Keep the blade off the neighbor parts
- Begin at 0.4V (0.5A). Is the cabin too heavy for that? Go up bit by bit, but not over the current on the motor's label
Motor and driver grow warm at a floor, too. Nothing turns there, but the holding current flows.
The Expansion Board
DIYables also makes a 42 x 42 mm carrier for this driver (a DRV8825 fits as well). The module stands in two 8-pin sockets, and around it you find:
- A G V S header with a row for EN, a row for STEP and a row for DIR. S means signal, V feeds VDD, G means ground. V and G run through all three rows, so wire each of them once, where you like
- A green screw terminal for the 12V of the adapter, with the screws VIN and GND. 12-24V is printed there, and the capacitor (100uF, 35V) is already soldered
- A white XH plug for the motor. Its pins from the top are 2B, 2A, 1A, 1B
- Three DIP switches for the step size
- Two jobs less: RST meets SLP on the board, and an empty EN row leaves the driver on
The V wire is no luxury here. A DRV8825 would manage without it, an A4988 would stay dead.
※ NOTE THAT:
Which way round? Both ways fit, but only one is right, and a module put in backwards can be destroyed. Compare two corners with the drawing: EN is in the left socket, near the G V S pins, and the small "VIN" arrow is where VMOT goes in.
※ NOTE THAT:
Would a DRV8825 do as well? Yes. With the power off, you could pull out one module and push in the other, because STEP and DIR work alike. Compared with the list above, the numbers are a bit bigger: 8.2V to 45V, around 1.5A per coil (cooled 2.2A), steps as fine as 1/32. And there is no V wire to think of. A paper cabin never asks for that much. Care is needed with the pins, because STEP is GPIO10 and DIR is GPIO9 on the page ESP32 C3 Super Mini - DRV8825 Stepper Motor Driver. Change them in the sketch if you swap the drivers.
Wiring Diagram between A4988 and ESP32 C3 Super Mini
Seat the ESP32 C3 Super Mini on the breadboard with the middle gap under it. You only need two breadboard columns. GPIO7 lies straight across the gap from 3.3, and GPIO6 straight across from G. So the half with the pins 21 to 5 delivers the two signals, and the half with the pins 0 to 5V delivers 3.3V and ground. A wire goes into any free hole of its column half, because these holes are joined with the pin.
Why GPIO6 and GPIO7? At power-up, the ESP32-C3 looks at GPIO2, GPIO8 and GPIO9, its boot strapping pins, to decide how to start. GPIO6 and GPIO7 are not asked, so a driver on them cannot disturb the start.
With the Expansion Board
The expansion board lies beside the breadboard. Take wires with a male end for the breadboard and a female end for the header. In the drawing, V and G are plugged into the DIR row, which you can see in the zoom. Any other row would be just as good.

This image is created using Fritzing. Click to enlarge image
| Expansion Board | Comes From |
|---|---|
| S pin of STEP | GPIO7 (printed "7") |
| S pin of DIR | GPIO6 (printed "6") |
| one V pin | 3.3V (printed "3.3") |
| one G pin | GND (printed "G") |
| EN row | empty |
| VIN screw | 12V from the + of the jack |
| GND screw | the - of the jack |
| 2B, 2A of the plug | wires A, C of the motor (black, green) |
| 1A, 1B of the plug | wires B, D of the motor (red, blue) |
※ NOTE THAT:
- 12V comes last. All other wires are in place before the adapter gets its wall socket. The 12V may only reach VIN (VMOT on the bare module). One touch of 12V on a C3 pin can ruin the board.
- One ground for all. Adapter minus, driver ground and G of the C3 form one common line.
- Move the motor plug only when 12V is off. A coil does not like to lose its current suddenly. It answers with a short peak of high voltage, which can destroy the A4988.
- Do not copy the motor colours of the drawing. Its brown, yellow, pink and purple were picked for the picture.
Without the Expansion Board
The bare module stays off the breadboard too, and the C3 keeps its four pins. Two small jobs move over to you: joining RST with SLP (the orange jumper) and adding a capacitor.

This image is created using Fritzing. Click to enlarge image
| A4988 Module | Comes From |
|---|---|
| STEP | GPIO7 |
| DIR | GPIO6 |
| VDD | 3.3V (printed "3.3") |
| lower GND (under VDD) | GND (printed "G") |
| VMOT | 12V from the + of the jack |
| upper GND (under VMOT) | the - of the jack |
| 2B, 2A | wires A, C of the motor |
| 1A, 1B | wires B, D of the motor |
| RST | SLP, one pin below (orange jumper) |
| EN, MS1, MS2, MS3 | empty (outputs on, full step) |
※ NOTE THAT:
- The jumper: forget it, and RST floats. The cabin may then never leave floor 0.
- The capacitor: it is missing in the drawing, but not in your circuit. Bridge VMOT and the upper GND with 100uF, close to the module, + leg to VMOT. 35V or more is the best rating for it. It softens the voltage jumps on the 12V line.
ESP32 C3 Super Mini Code - Stepper Motor A4988 Driver
Sketch number one checks the wires, the current and the direction. It needs no library, and the cabin may still be missing.
What the code does:
- Makes GPIO7 (STEP) and GPIO6 (DIR) outputs
- Builds each step from a HIGH and a LOW of 2000 microseconds each
- Sets DIR first and lets 5 microseconds pass before the pulses begin
- Turns the spool up once with 200 pulses, waits 2.2 seconds, turns it down once and waits again
- Divides the pulse time by MICROSTEPS, so a turn takes 0.8 seconds in every step size
Detailed Instructions
- New board? Do the page Getting Started with ESP32 C3 Super Mini before this one. It brings the ESP32 boards into the Arduino IDE.
- DIP switches: None of the three is ON. No wire on the MS pins means the same for the bare module.
- Circuit: Copy the drawing wire by wire, without power on the 12V side.
- VREF: Give the C3 its USB-C cable, then bring the trimmer to your value, as explained above.
- Arrow: A paper arrow, held on the shaft by tape, will show you every turn.
- Board: In the Tools menu, take ESP32C3 Dev Module and the COM port of the C3.
- Sketch: Put the code into a new Arduino IDE window and press Upload.

- Text: Start the Serial Monitor with 115200 baud.
- Motion: 12V on! Compare the arrow with the text:
- What to look at: The arrow has to rest where it started, trip after trip. During a wait, pinch the shaft and try to twist it: it fights back. This is the force that carries the cabin. The speed, 75 RPM, is calm enough to start without a ramp.
- Down instead of up? Exchange the words HIGH and LOW in the lines of UP and DOWN. The other way is hardware: pull the adapter, then put the red motor wire where the blue one was, and the blue one where the red one was.
- Pro Tip: No text at all? Look in the Tools menu: the line USB CDC On Boot has to say Enabled. Change it and send the sketch once more.
ESP32 C3 Super Mini Code - Model Lift with Soft Start and Stop
A real lift does not jump. So this time the AccelStepper library makes the pulses. It puts long gaps between them at first, then shorter ones, and long ones again before the stop.
What the code does:
- Creates the motor in the AccelStepper::DRIVER mode, which needs two pin numbers: first STEP, then DIR
- Allows 450 steps per second at most, and lets the speed change by 300 of them within a second
- Counts down from 8 at the start, so you can reach for the adapter
- Calls the starting place floor 0, then visits floor 1, 3, 0 and 2, again and again
- Multiplies the floor number by 300 steps to get the target for moveTo()
- Repeats run() in a while loop until the cabin has arrived, with no delay() on the way
- Prints the floor and the ride time, and keeps the doors open for 3 seconds
Detailed Instructions
- Library: Open the Library Manager of the Arduino IDE, type "AccelStepper" and install the library of Mike McCauley.
- Search for AccelStepper created by Mike McCauley
and click the Install button.
- 12V out: Pull the adapter. Without 12V, the spool can be turned by hand.
- Cabin on floor 0: Let the cabin down to its lowest place. The C3 has no eyes, so it trusts you on this.
- Upload: Send the sketch to the board and open the Serial Monitor (115200 baud).
- 12V in: Plug in the adapter before the countdown is over. Too late? Pull the adapter, bring the cabin back to floor 0 and press RST on the C3: it counts from 8 again.
- Watch the ride: Each line tells you where the cabin is going and where it has stopped:
- What to look at: Compare the times. Three floors take less than twice as long as one floor. On a short ride, the motor is still gaining speed when it already has to slow down. Only the three-floor ride reaches 450 steps per second.
- Softer or faster? Set ACCELERATION to 120 for a sleepy old lift, or TOP_SPEED and ACCELERATION to 700 for a skyscraper. If the cabin no longer stops level, go back a little.
- Other house? Change STEPS_PER_FLOOR to your floor height and ROUTE to your own list of floors.
- Pro Tip: Without 12V, nothing holds the cabin and it sinks. Real lifts have a counterweight, and yours can have one too: hang it on a second thread, wound around the spool the other way. It goes down when the cabin goes up, and it takes work off the motor. And it is a toy, so the cabin is for dolls only.
Line-by-line Code Explanation
The above ESP32 C3 Super Mini code contains line-by-line explanation. Please read the comments in the code!
Troubleshooting
- Dead lift, and the spool is loose: The chip has no 3.3V, no 12V, or it is asleep. Trace the red wire from 3.3 to V (VDD), feel if the adapter plug is in, and look for the orange jumper on the bare module.
- Dead lift, but the spool is locked: The driver is awake and waits for pulses. Follow the wire from GPIO7 to STEP.
- Growling or trembling on the spot: Sort the motor wires again, the coil pairs may be mixed. If they are fine, ask less of the motor (a smaller TOP_SPEED, a smaller ACCELERATION) or feed it a little more VREF.
- Every ride goes the wrong way: Pull the adapter and reverse one coil. For example, what was on 2B goes to 2A, and the other way round.
- Hot driver, and the cabin drops now and then: That is the over-temperature shutdown. Reduce VREF, and let the heat sink do its part.
- The cabin stops between two floors: Compare MICROSTEPS with the DIP switches, and remember that MS1 is the last switch.
- The floors drift away after many rides: Some steps get lost. Try a lighter cabin, a softer ACCELERATION, or a bit more VREF.
Applications and Project Ideas
Floors are only one way to use counted steps. With the WiFi and Bluetooth LE of the C3, the same circuit can become:
- Shop window lift: show a new product on every floor, and stop longer at the special offer
- Advent calendar house: one ride per day, to the window with the right date
- Dumbwaiter for a board game: send cards or snacks to the upper end of the table
- Bird feeder hoist: pull the feeder up to the branch, and let it down for refilling
- Cable car: move a gondola between two shelves, with a stop at each book end
- Talking lift: let a mini MP3 player module announce the floors
Video Tutorial
Challenge Yourself
- Easy: Add a 4 to ROUTE and find out how many steps floor 4 needs. Is your thread long enough?
- Easy: Set MICROSTEPS to 8, turn on the DIP switches 3 and 2, and listen to the difference
- Medium: Show the floor number on a 128x64 OLED while the doors are open
- Medium: Call the lift with a keypad: the keys 0 to 3 choose the floor
- Advanced: Hide a limit switch under floor 0. At every start, let the cabin sink slowly until it presses the switch, so nobody has to place it by hand
- Advanced: Collect several calls during a ride, and visit the floors in a clever order, as a real lift does