Stepper 28BYJ48 practical reference
A cheap 5V geared stepper motor bundled with the ULN2003 driver board, common in camera sliders and small CNC-style projects.
Key specifications
- Motor type: 5-wire unipolar stepper with internal ~1:64 gear reduction
- Step angle: 5.625°/64 per internal step — roughly 4096 half-steps per output-shaft revolution through the gearbox
- Operating voltage: 5 V DC (matches the bundled ULN2003 driver board; a 12V-coil variant also exists)
- Driver IC: ULN2003 Darlington transistor array, 4 inputs (IN1-IN4)
- Current draw: ~240 mA per phase — low torque, not suited to driving loads heavier than light gears or small pointers
Pinout and connection notes
The motor connects to the driver board via its own keyed JST connector, not loose wires — only IN1-IN4 and the power terminal go to your microcontroller and supply.
- IN1: Coil control input 1 — connect to a digital output pin
- IN2: Coil control input 2 — connect to a digital output pin
- IN3: Coil control input 3 — connect to a digital output pin
- IN4: Coil control input 4 — connect to a digital output pin
- -: Ground, on the driver board's power terminal
- +: Power, 5V DC, on the driver board's power terminal — the motor's 5-pin JST plugs directly into the driver, no separate motor wiring needed
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
ULN2003 wiring and step-sequence checks
The 28BYJ-48 is commonly supplied as a five-wire unipolar motor with a matching ULN2003 driver board. The driver board switches the motor coil connections; it is not a precision current-regulating chopper driver. Confirm the motor and board variant before applying power, and use the board's labelled connector rather than assuming the order of loose motor wires.
If the motor only vibrates, check that the four control inputs are connected in the expected order and that the firmware's phase sequence matches the motor/driver arrangement. If it rotates in the wrong direction, reverse the sequence in software rather than swapping supply wires. Missed steps can result from excessive speed, a sudden acceleration command, insufficient supply current or mechanical load. Start slowly, then increase speed while checking that the shaft follows the commanded steps.
The commonly quoted step count per output revolution depends on the exact gearbox ratio and whether the library counts full steps or half steps. Calibrate actual travel against a marked shaft or pointer before using step counts as a position measurement. This motor is not inherently closed-loop: it cannot report that it has missed steps. Use a home switch or other position reference when repeatable absolute positioning matters.
Wiring & code
Board integration
Library
AccelStepper by Mike McCauley
Arduino IDE → Tools → Manage Libraries → search "AccelStepper"
Wiring
| Component pin | ESP32 pin | Note |
|---|---|---|
| IN1 | GPIO14 | |
| IN2 | GPIO27 | |
| IN3 | GPIO26 | |
| IN4 | GPIO25 | |
| + | 5V (external supply recommended) | The ULN2003 board's onboard regulation is minimal -- an external 5V supply avoids brownouts on the ESP32 when the motor is under load |
| - | GND | Common ground with the ESP32 is required even with an external supply |
#include <AccelStepper.h>
// ULN2003 half-step sequence -- note the IN2/IN3 order swap
AccelStepper stepper(AccelStepper::HALF4WIRE, 14, 26, 27, 25);
void setup() {
stepper.setMaxSpeed(1000);
stepper.setAcceleration(200);
stepper.moveTo(4096); // ~one full revolution in half-step mode
}
void loop() {
if (stepper.distanceToGo() == 0) {
stepper.moveTo(-stepper.currentPosition());
delay(500);
}
stepper.run();
}AccelStepper's HALF4WIRE mode expects pins in IN1-IN3-IN2-IN4 order, not IN1-IN2-IN3-IN4 -- get this wrong and the motor buzzes without turning. ~4096 half-steps make one full revolution on the standard 28BYJ-48 gearing.
