How-to · Beginner · 3 min read
28BYJ-48 Stepper Motor with ULN2003 Driver
Wiring and Code
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
The 28BYJ-48 is a small 5 V geared stepper motor sold with a ULN2003 driver board. Wire IN1 to IN4 to four pins, power the board from 5 V that can give about 250 mA, and use the Stepper or AccelStepper library. One shaft turn is about 2048 full steps or 4096 half steps. It is slow, around 10 to 15 RPM, but precise and cheap.
Key specs at a glance
- Voltage
- 5 V (12 V versions exist)
- Gear ratio
- About 64:1 (exactly about 63.68:1)
- Steps per revolution
- About 2048 full-step, 4096 half-step
- Speed
- About 10 to 15 RPM maximum
- Current
- About 200 to 250 mA with two coils on
- Torque
- About 300 g·cm (roughly 0.03 N·m)
Wiring the ULN2003 board
| ULN2003 pin | Arduino Uno | ESP32 | Notes |
|---|---|---|---|
| IN1 | D8 | GPIO 19 | |
| IN2 | D9 | GPIO 18 | |
| IN3 | D10 | GPIO 5 | |
| IN4 | D11 | GPIO 17 | |
| + (5 to 12 V) | External 5 V | External 5 V | Not the Arduino 5V pin for more than one motor |
| - | GND | GND | Common ground with the board |
| Motor socket | 28BYJ-48 white plug | Keyed, plugs in one way |
- IN1
- Arduino Uno:
- D8
- ESP32:
- GPIO 19
- IN2
- Arduino Uno:
- D9
- ESP32:
- GPIO 18
- IN3
- Arduino Uno:
- D10
- ESP32:
- GPIO 5
- IN4
- Arduino Uno:
- D11
- ESP32:
- GPIO 17
- + (5 to 12 V)
- Arduino Uno:
- External 5 V
- ESP32:
- External 5 V
- Notes:
- Not the Arduino 5V pin for more than one motor
- -
- Arduino Uno:
- GND
- ESP32:
- GND
- Notes:
- Common ground with the board
- Motor socket
- Arduino Uno:
- 28BYJ-48 white plug
- Notes:
- Keyed, plugs in one way
The pin order trap: 8, 10, 9, 11
The Arduino Stepper library energises coils in the order of the pins you give it, and the 28BYJ-48 needs IN1, IN3, IN2, IN4. So wiring IN1 to IN4 to pins 8, 9, 10, 11 means you must declare the pins as 8, 10, 9, 11. If the motor only vibrates or turns one way, this is almost always the cause.
Arduino code
The built-in Stepper library is enough for simple moves; AccelStepper adds acceleration and non-blocking control.
#include <Stepper.h>
const int STEPS_PER_REV = 2048; // full-step mode
Stepper motor(STEPS_PER_REV, 8, 10, 9, 11); // note the order
void setup() {
motor.setSpeed(12); // RPM, keep under about 15
}
void loop() {
motor.step(STEPS_PER_REV); // one turn clockwise
delay(500);
motor.step(-STEPS_PER_REV); // one turn back
delay(500);
}
// AccelStepper version (half-step, smoother):
// #include <AccelStepper.h>
// AccelStepper m(AccelStepper::HALF4WIRE, 8, 10, 9, 11);
// setup(): m.setMaxSpeed(1000); m.setAcceleration(500); m.moveTo(4096);
// loop(): m.run();Power, heat and saving energy
The coils draw current even when the motor is still, so the motor and the ULN2003 get warm. For one motor, USB power works; for two or more, use a separate 5 V supply of 1 A or more and share ground. When the motor does not need to hold its position, switch all four outputs LOW (for example with digitalWrite to each pin) to cut current to zero. ESP32 and Pico 3.3 V outputs drive the ULN2003 inputs fine.
When to move to a bigger stepper
The 28BYJ-48 is slow and has gear backlash of a degree or two, so it cannot drive a 3D printer axis or a fast robot. For more speed and torque, use a NEMA 17 motor with an A4988, DRV8825 or TMC2209 driver; see stepper drivers compared and the stepper motors guide. Advanced users can convert a 28BYJ-48 to bipolar by cutting the red common wire's PCB trace, which roughly doubles the torque with a bipolar driver.
Try it: Stepper steps per mm calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Declaring the pins as 8, 9, 10, 11 so the motor just buzzes.
- Setting the speed above 15 RPM, which makes it stall.
- Powering several motors from the Arduino 5V pin.
- Leaving coils energised all day and wondering why it is hot.
- Expecting exactly 2048 steps per turn for precise long-term counting; the real gear ratio is slightly different.
Frequently asked questions
How many steps per revolution does the 28BYJ-48 have?
About 2048 steps in full-step mode and 4096 in half-step mode at the output shaft. The exact gear ratio makes it about 2037.9 full steps.
Why does my 28BYJ-48 only vibrate?
The pin order is wrong. With the Stepper library and IN1 to IN4 on pins 8 to 11, declare the pins as 8, 10, 9, 11.
How fast can the 28BYJ-48 turn?
About 10 to 15 RPM at 5 V. Faster settings make it miss steps or stall.
Can I use the 28BYJ-48 with ESP32?
Yes. The ESP32's 3.3 V outputs drive the ULN2003 inputs. Power the motor board from 5 V and share ground.
Can an A4988 drive a 28BYJ-48?
Only after converting the motor to bipolar by cutting the trace for the red common wire. Otherwise use the ULN2003 board.
Parts for this guide
Calculators
Terms in this guide
Projects that use it
Put this into practice: 17 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
- Kiatronics 28BYJ-48 motor datasheet
- Texas Instruments ULN2003A datasheet
- Arduino Stepper and AccelStepper library documentation
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.



