Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

28BYJ-48 stepper and ULN2003 with Arduino Uno — wiring and code

Drive a 28BYJ-48 stepper through a ULN2003 board from an Arduino Uno R3 on D8–D11 with the Stepper library — the right coil order and a 5 V supply.

Arduino C++Verified — core avr 1.8.8, Stepper 1.1.3, 3 Nov 2026Compile-only

Community draft — report a mistake

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 R3Only the pins used are shown · 5 V logic5 V 1 A adapter28BYJ-48 stepper motor + ULN2003 driver+5VGNDGNDD8D9D10D11IN1IN2IN3IN4+-
Also needed: 28BYJ-48 5 V stepper motor (plugs into the white socket).
Every connection
Arduino Uno R328BYJ-48 stepper motor + ULN2003 driverWireNotes
D8IN1blue
D9IN2purple
D10IN3yellow
D11IN4orange
5 V 1 A adapter · +5V+redAbout 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-blackCommon 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 in HALF4WIRE mode.
  • Buy the 5 V version of the motor. The 12 V version looks the same and barely moves on 5 V.

Code

uln2003-uno.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// 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

Serial Monitor · 9600Output
28BYJ-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.

↑↓ to move · Enter to open