28BYJ-48 Stepper Motor & ULN2003 Driver Control
Command exact sub-degree angular rotations using a 64:1 geared unipolar stepper motor and ULN2003 Darlington array.
Step into precision open-loop motion control with the 28BYJ-48 5V stepper motor and ULN2003 driver board. Learn how sequential 4-coil energization moves the rotor by exact discrete increments (2048 full steps per revolution) for CNC axes, camera pan rigs, and clock hands.
Key Learning Objectives & Robotics Concepts
By building and programming this project, you will master the following core engineering skills:
Power Architecture & Voltage Staging
5V / 3.3V Regulated PowerThe 28BYJ-48 draws ~200–240mA continuously across two energized stator coils. For reliable torque without stressing Arduino's onboard regulator, power the ULN2003 5V-12V jumper header from an external 5V supply with GND tied to Arduino GND. ULN2003 includes internal flyback clamping diodes for coil inductance; de-energize coils when idle to prevent unnecessary heating.
Bill of Materials (BOM) & Hardware Components
| Component | Specifications & Alternative | Qty | Approx Cost |
|---|---|---|---|
| Arduino Uno R3 | ATmega328P @ 16MHz | 1 | $8.00 |
| 28BYJ-48 5V Unipolar Stepper Motor | 64:1 internal gearbox, 2048 full steps/rev | 1 | $2.50 |
| ULN2003 Stepper Driver Board | 7-channel Darlington sink array + 4 phase LEDs | 1 | $1.50 |
| External 5V Supply / Jumper Wires | 5V 1A power + 6 jumper leads | 1 | $2.00 |
Electrical & System Architecture
Plug the 5-wire 28BYJ-48 JST connector into the ULN2003 board. Wire ULN2003 IN1→D8, IN2→D9, IN3→D10, IN4→D11, plus 5V and common GND.
Autonomous Behavior & Finite State Machine (FSM)
Deterministic Arduino loop handling 28BYJ-48 5V Stepper + ULN2003 Driver Board acquisition, filtering, and real-time output updates.
Step-by-Step Physical Assembly & Wiring Tutorial
Follow each of the 5 sequential milestone stages with technical photos, wiring checks, and pre-flight tests.
Inspect ULN2003 Power Jumper & JST Socket
Confirm the small 2-pin jumper cap next to the power header is installed (enables motor power).
- Plug the white 5-pin JST cable from the 28BYJ-48 into the ULN2003 socket (keyed one way).
- Confirm the yellow/black power-enable jumper cap sits across the two pins beside the +/- header.
- Attach a small flag of tape to the motor shaft so rotation angle is easy to see.
Wire IN1–IN4 to Pins D8–D11
Connect control inputs sequentially and establish a clean common ground.
- Connect ULN2003 IN1→D8, IN2→D9, IN3→D10, IN4→D11.
- Connect ULN2003 (-) to Arduino GND (and external 5V PSU negative if used).
- Connect ULN2003 (+) to 5V power rail.
Run Slow Phase-LED Diagnostic
Verify ULN2003 LEDs A→B→C→D illuminate one by one in smooth sequence.
- Upload the diagnostic sketch below.
- Watch LEDs A, B, C, D chase smoothly while the shaft crawls forward.
- If the motor vibrates in place without turning, check the (8, 10, 9, 11) pin sequence.
Upload Full Revolution CW/CCW Firmware
Flash the precision angular controller and observe exact 360° clockwise and 180° counter-clockwise turns.
- Upload the production sketch below.
- Watch your tape flag rotate an exact full circle (+360°), pause coolly, then return half a turn (-180°).
- Check Serial Monitor for live step count and angle logs.
Tune RPM & Torque Balance
Test speeds between 5 RPM (highest torque) and 13 RPM (fastest reliable slew).
- Try setSpeed(6) vs setSpeed(12) and observe quiet smoothness.
- Confirm motor casing remains comfortably warm after 2 minutes of operation.
- Verify shaft returns accurately to its starting tape mark.
Subsystem Benchtop Verification Scripts
Test each hardware subsystem independently before deploying the full autonomous firmware.
1Bench Diagnostic: 28BYJ-48 5V Stepper + ULN2003 Driver Board Hardware Check
Subsystem DiagnosticMinimal standalone sketch to verify pin wiring and signal response for 28BYJ-48 5V Stepper + ULN2003 Driver Board before running the full project firmware.
// Diagnostic: ULN2003 Coil Phase LED Chase Check
void setup() { for (int p=8; p<=11; p++) pinMode(p, OUTPUT); }
void loop() {
for (int p=8; p<=11; p++) { digitalWrite(p, HIGH); delay(250); digitalWrite(p, LOW); }
}Complete Production Firmware
Full working C++ source code with pin mappings, non-blocking timers, and FSM avoidance routines.
/**
* Project 15: 28BYJ-48 Stepper Motor Precision Controller
* Board: Arduino Uno R3 | ULN2003: IN1=D8, IN2=D9, IN3=D10, IN4=D11
*/
#include <Stepper.h>
const int STEPS_PER_REV = 2048; // 64:1 gear ratio full-step mode
// Note: 28BYJ-48 requires IN1-IN3-IN2-IN4 order for Arduino Stepper.h
Stepper motor(STEPS_PER_REV, 8, 10, 9, 11);
void releaseCoils() {
for (uint8_t p = 8; p <= 11; p++) digitalWrite(p, LOW);
}
void rotateDegrees(float deg) {
long steps = (long)((deg / 360.0f) * STEPS_PER_REV);
Serial.print(F("Rotating ")); Serial.print(deg, 1);
Serial.print(F(" deg (")); Serial.print(steps); Serial.println(F(" steps)"));
motor.step(steps);
releaseCoils();
}
void setup() {
Serial.begin(115200);
motor.setSpeed(11); // Optimal smooth RPM for 5V 28BYJ-48
Serial.println(F("28BYJ-48 Stepper Controller Ready"));
}
void loop() {
rotateDegrees(360.0);
delay(1500);
rotateDegrees(-180.0);
delay(1500);
}Firmware Architecture Explanation:
- Passes pin sequence (8, 10, 9, 11) so Stepper.h energizes the 28BYJ-48 stator coils in proper spatial order.
- Converts human-friendly degree targets into exact integer steps using 2048 steps per revolution.
- Calls releaseCoils() after every move to cut standby current to 0mA and keep the motor cool.
Operational Verification & Pin State Matrix
Input Signal vs. System Output Truth Table:
| Input / State | Pin / Signal | Detected Condition | Expected Output |
|---|---|---|---|
| Positive Steps | IN1→IN3→IN2→IN4 | Clockwise Sequence | Shaft Rotates CW |
| Negative Steps | IN4→IN2→IN3→IN1 | Counter-Clockwise | Shaft Rotates CCW |
| Idle Pause | All Pins LOW | Coils Released | 0mA Cool Standby |
Engineering Troubleshooting Matrix
| Problem | Likely Cause | Diagnostic Check | Engineering Solution |
|---|---|---|---|
| Motor hums and vibrates without spinning | Pin order passed as (8,9,10,11) instead of (8,10,9,11) or RPM too high | Check Stepper constructor and setSpeed value | Use Stepper(2048, 8, 10, 9, 11) and keep speed ≤12 RPM. |
| Motor turns only in one direction (never reverses) | One of the four coil pins disconnected or mis-ordered | Run Phase LED diagnostic to verify all 4 LEDs light | Re-seat IN1–IN4 jumpers and check JST plug. |
| Motor feels very hot while stopped | Coils left continuously energized at standstill | Check if two ULN2003 LEDs stay lit during pause | Call releaseCoils() whenever holding torque is not needed. |
Engineering Challenges & Upgrades
Take your build to the next level with these progressive engineering upgrades:
Pair with Project 16 (KY-040) so every click of the knob steps the motor 15° CW or CCW.
Advance the shaft 6° (34 steps) every second synchronized with Project 18 (DS3231 RTC).
Type any degree angle in Serial Monitor to rotate a 3D-scanning turntable smoothly.