28BYJ-48 stepper + ULN2003 with Arduino: wiring, code and common problems
How to wire the 28BYJ-48 stepper to a ULN2003 board and Arduino, AccelStepper code for continuous speed and fixed angles, and why it buzzes but won't turn.
Published

The 28BYJ-48 is the cheapest, most widely available stepper motor, usually sold with a ULN2003 driver board. It is weak and slow, but it runs quietly, has a gearbox built in and runs fine from 5V USB. It drives the channel’s 360° turntable.
Specs worth knowing
| Spec | Value |
|---|---|
| Voltage | 5V (a 12V version exists, check the label on the back) |
| Type | Unipolar, 5 wires |
| Gearbox | About 1:64 |
| Steps per output revolution | About 2048 (full-step) or 4096 (half-step) |
| Practical top speed | About 10–15 rpm |
| Current | About 200–250 mA, fine from a USB port |
Because of the gearbox, the output shaft has a little backlash when changing direction. That is fine for a turntable or a clock hand; for precise positioning use a NEMA17.
Wiring
The motor plugs straight into the 5-pin socket on the ULN2003 board (it is keyed, so it cannot go in backwards).
| Arduino | ULN2003 |
|---|---|
| D8 | IN1 |
| D9 | IN2 |
| D10 | IN3 |
| D11 | IN4 |
| 5V | + |
| GND | − |
If you power the motor from a separate 5V supply (recommended for several motors), connect the supply GND to the Arduino GND.
Continuous speed
Install the AccelStepper library (Arduino IDE: Sketch → Include Library → Manage Libraries, search for “AccelStepper”).
#include <AccelStepper.h>
// Order 8, 10, 9, 11 (IN1, IN3, IN2, IN4) is required for the 28BYJ-48
AccelStepper motor(AccelStepper::HALF4WIRE, 8, 10, 9, 11);
void setup() {
motor.setMaxSpeed(1000); // steps per second (half-step)
motor.setSpeed(500); // positive = clockwise, negative = reverse
}
void loop() {
motor.runSpeed(); // call constantly, no delay() in loop
}
In half-step mode 4096 steps make one revolution, so 1000 steps per second ≈ 14.6 rpm: close to this motor’s limit.
Turn to an angle and stop
#include <AccelStepper.h>
AccelStepper motor(AccelStepper::HALF4WIRE, 8, 10, 9, 11);
const long STEPS_PER_REV = 4096;
void setup() {
motor.setMaxSpeed(800);
motor.setAcceleration(400); // smooth ramp, no jerk
motor.moveTo(STEPS_PER_REV / 4); // turn 90°
}
void loop() {
if (motor.distanceToGo() == 0) {
motor.disableOutputs(); // switch coils off to keep it cool
} else {
motor.enableOutputs();
motor.run();
}
}
Common problems
- Motor buzzes and vibrates but does not turn: wrong pin order. The declaration must be
8, 10, 9, 11, not8, 9, 10, 11. - Turns but skips steps or stutters: too fast. Lower
setMaxSpeedto 600–800 and addsetAcceleration. - Motor and board get hot while idle: the coils are still powered. Call
disableOutputs()when you do not need to hold position. - Slower than expected:
delay()or heavySerial.printinloop().runSpeed()/run()must be called constantly. - Using an A4988 with the 5V 28BYJ-48: it will not work. The A4988 drives bipolar motors and needs 8V or more, while the 5V version is unipolar. Use the ULN2003, or move to a NEMA17 if you want an A4988.