The 28BYJ-48 is the small geared stepper motor sold with a ULN2003 driver board in most Indian starter kits for about ₹150. It turns slowly but precisely, which suits clock hands, rotating displays and small valve or curtain projects.
The ULN2003 board is four transistor switches with LEDs that show which coil is on. On the Uno the four inputs go to D8–D11, which leaves the PWM pins D3, D5 and D6 free. The motor gets its own 5 V supply with the ground shared with the Uno.
The one thing that trips everyone up is the coil order. The built-in Stepper library needs the pins in the order IN1, IN3, IN2, IN4. The sketch makes one full turn each way, then switches the coils off so the motor doesn’t heat up while it waits.
Wiring
| Arduino Uno R3 | 28BYJ-48 stepper motor + ULN2003 driver | Wire | Notes |
|---|---|---|---|
| D8 | IN1 | blue | |
| D9 | IN2 | purple | |
| D10 | IN3 | yellow | |
| D11 | IN4 | orange | |
| 5 V 1 A adapter · +5V | + | red | About 240 mA while stepping. One motor can run from the Uno’s 5V pin on USB for a test; a separate 5 V supply is steadier. |
| 5 V 1 A adapter · GND | - | black | |
| GND | - | black | Common ground with the Uno. |
5 V for the 5 V version of the motor (about 200–250 mA while stepping) part, 5 V board. The ULN2003 inputs accept 3.3 V or 5 V logic, so ESP32 and Pico drive IN1–IN4 directly. Power the motor from 5 V — not from a 3.3 V pin — and share GND with the board.
Board quirks
- The Stepper library expects the coils as IN1, IN3, IN2, IN4 — hence
Stepper(2048, 8, 10, 9, 11). With 8, 9, 10, 11 the motor only buzzes or shakes back and forth. - One output shaft turn is 2048 full steps (some listings say 2038 — the gear ratio is really 63.68:1, so 2048 is very slightly more than one turn).
- Top speed is about 15 rpm. Set it higher and the motor stalls and hums.
step()blocks: the Uno does nothing else until the move ends. For moving and reading sensors at the same time, use AccelStepper inHALF4WIREmode.- Buy the 5 V version of the motor. The 12 V version looks the same and barely moves on 5 V.
Code
// 28BYJ-48 stepper + ULN2003 driver board on an Arduino Uno R3.
// IN1 → D8, IN2 → D9, IN3 → D10, IN4 → D11. + → 5 V supply, − → GND (shared with the Uno).
// The motor plugs into the white 5-pin socket on the driver board.
#include <Stepper.h>
const int STEPS_PER_REV = 2048; // 28BYJ-48 in full-step mode (32 steps x 64:1 gearbox)
// Note the order: IN1, IN3, IN2, IN4 - the Stepper library needs the coils in this sequence.
Stepper motor(STEPS_PER_REV, 8, 10, 9, 11);
void releaseCoils() {
// The library leaves the last coils on; switch them off so the motor doesn't heat up.
for (uint8_t p = 8; p <= 11; p++) digitalWrite(p, LOW);
}
void setup() {
Serial.begin(9600);
motor.setSpeed(12); // rpm; above about 15 the 28BYJ-48 starts skipping steps
Serial.println(F("28BYJ-48: one turn clockwise, one anticlockwise"));
}
void loop() {
Serial.println(F("Clockwise 360"));
motor.step(STEPS_PER_REV);
releaseCoils();
delay(1000);
Serial.println(F("Anticlockwise 360"));
motor.step(-STEPS_PER_REV);
releaseCoils();
delay(1000);
}// 28BYJ-48 stepper + ULN2003 driver board on an Arduino Uno R3.
// IN1 → D8, IN2 → D9, IN3 → D10, IN4 → D11. + → 5 V supply, − → GND (shared with the Uno).
// The motor plugs into the white 5-pin socket on the driver board.
#include <Stepper.h>
const int STEPS_PER_REV = 2048; // 28BYJ-48 in full-step mode (32 steps x 64:1 gearbox)
// Note the order: IN1, IN3, IN2, IN4 - the Stepper library needs the coils in this sequence.
Stepper motor(STEPS_PER_REV, 8, 10, 9, 11);
void releaseCoils() {
// The library leaves the last coils on; switch them off so the motor doesn't heat up.
for (uint8_t p = 8; p <= 11; p++) digitalWrite(p, LOW);
}
void setup() {
Serial.begin(9600);
motor.setSpeed(12); // rpm; above about 15 the 28BYJ-48 starts skipping steps
Serial.println(F("28BYJ-48: one turn clockwise, one anticlockwise"));
}
void loop() {
Serial.println(F("Clockwise 360"));
motor.step(STEPS_PER_REV);
releaseCoils();
delay(1000);
Serial.println(F("Anticlockwise 360"));
motor.step(-STEPS_PER_REV);
releaseCoils();
delay(1000);
}Library: Stepper (Arduino) — compiled with Stepper 1.1.3.
Expected serial output
28BYJ-48: one turn clockwise, one anticlockwise
Clockwise 360
Anticlockwise 36028BYJ-48: one turn clockwise, one anticlockwise Clockwise 360 Anticlockwise 360
Common errors
Motor vibrates but doesn’t turn
Coil order. Use Stepper(2048, 8, 10, 9, 11), with IN1–IN4 on D8–D11 as wired.
LEDs on the board light, motor doesn’t move
Speed too high or not enough current. Lower setSpeed() to 10 and power the + pin from a proper 5 V supply.
Motor gets hot while standing still
Coils stay energised after a move. The sketch switches them off with releaseCoils() — keep that if the motor doesn’t need to hold a load.