Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.

28BYJ-48 ULN2003 Arduino: Cheap Stepper Tutorial – Complete Beginner’s Guide

As a PCB engineer who’s designed motor control circuits for over a decade, I’ve tested dozens of stepper motors across various price points. The 28BYJ-48 ULN2003 Arduino combination stands out as the absolute best entry point for anyone learning about stepper motor control. At under $3 for the complete kit, this setup delivers more educational value per dollar than any other motor I’ve encountered.

What makes this combination particularly brilliant for beginners is its plug-and-play nature. Unlike NEMA stepper motors that require current limiting and complex driver configuration, the 28BYJ-48 with its ULN2003 board lets you go from unboxing to controlled rotation in under ten minutes. In this comprehensive guide, I’ll walk you through everything from basic wiring to advanced control techniques, including the critical details that many tutorials skip.

Understanding the 28BYJ-48 Stepper Motor

What Makes This Motor Special

The 28BYJ-48 represents the perfect intersection of affordability and functionality for learning projects. Originally designed for controlling air conditioner vanes and automotive mirror adjustments, this motor has found widespread adoption in the maker community because it does one thing exceptionally well: providing precise, repeatable positioning at minimal cost.

The “28” in the model name refers to the motor’s 28mm diameter body. The motor features a permanent magnet rotor surrounded by electromagnetic coils, operating on the fundamental principle of electromagnetism. By energizing these coils in specific sequences, we create magnetic fields that pull the rotor through discrete steps.

Key Physical Characteristics:

SpecificationValueEngineering Notes
Body Diameter28mmCompact design for space-constrained projects
Shaft TypeDouble-D (flat on two sides)Prevents wheel slippage when secured with set screw
Weight37gLightweight for mobile robots and drones
MountingTwo 3.5mm holesStandard spacing for mounting brackets
Operating Voltage5V DCDirect compatibility with Arduino logic levels
Current Draw240mA per phaseTotal ~160-240mA typical operation
Holding Torque34.3 mN·m (approximately 350 gf·cm)Adequate for small loads
Maximum Speed~15 RPMGear reduction limits rotational velocity
Step Angle (internal)5.625°Before gearbox reduction
Wire Count5 wires (unipolar)Simplifies driver requirements
Temperature Range-10°C to +50°CSuitable for indoor applications

The Gear Reduction Mystery Solved

Here’s where things get interesting from an engineering perspective. The manufacturer’s datasheet claims a 64:1 gear reduction ratio, giving you 2048 steps per revolution in full-step mode (32 internal steps × 64 gear ratio). However, members of the Arduino community actually disassembled these motors and counted the gear teeth.

The Real Gear Ratio:

The actual gear ratio is 63.68395:1, calculated from the internal gear train:

(32 × 22 × 32 × 22) / (9 × 10 × 9 × 10) = 63.68395

This means the true steps per revolution are:

  • Full-step mode: 32 × 63.68395 = 2038 steps (not 2048)
  • Half-step mode: 64 × 63.68395 = 4076 steps (not 4096)

For most hobby projects, this 0.5% difference won’t matter. But for precision applications like clock mechanisms or long-running position tracking, using 2038 instead of 2048 prevents cumulative positioning errors over time.

Important Note: Some manufacturers produce variants with different gear ratios. I’ve seen 1:16 reduction motors labeled as 28BYJ-48 that deliver only 512 steps per revolution. Always verify your specific motor’s performance if precision matters.

Unipolar vs Bipolar: Why This Motor is Beginner-Friendly

The 28BYJ-48 uses a unipolar configuration, which fundamentally simplifies the driver electronics compared to bipolar stepper motors.

Technical Breakdown:

Inside the motor, you’ll find two center-tapped electromagnetic coils. This center-tap connection allows current to flow through only half of each coil at a time, always in the same direction. The driver simply switches which half of the coil is energized.

Comparison with Bipolar Motors:

Feature28BYJ-48 (Unipolar)NEMA 17 (Bipolar)
Winding TypeCenter-tapped coilsSingle winding per phase
Current DirectionUnidirectionalMust reverse (requires H-bridge)
Driver ComplexitySimple transistor arrayComplex H-bridge circuit
Torque OutputLower (~70% of bipolar)Higher (full coil utilization)
Cost$2-3 complete kit$8-20 motor + $2-5 driver
Setup DifficultyBeginner-friendlyIntermediate (current limiting required)

This is why the 28BYJ-48 ULN2003 Arduino combination is perfect for learning—you get reliable operation without wrestling with current adjustment potentiometers or risking motor damage from incorrect settings.

Understanding the ULN2003 Driver Board

Why You Absolutely Need This Driver

Many beginners ask: “Can’t I just connect the motor directly to Arduino?” The answer is an emphatic no, and understanding why teaches important lessons about current capacity and motor control.

The Current Problem:

Arduino digital pins can safely source approximately 20-40mA per pin. The 28BYJ-48 stepper motor draws roughly 240mA per phase during operation. That’s six times more current than Arduino can provide. Attempting direct connection will:

  1. Cause immediate voltage drops on the Arduino 5V rail
  2. Trigger brownout resets (the Arduino will keep restarting)
  3. Potentially damage the ATmega328P microcontroller
  4. Create erratic motor behavior and missed steps

The ULN2003 Solution:

The ULN2003 chip contains seven Darlington transistor pairs, functioning as high-current switches. Each pair can handle up to 500mA at 50V—more than sufficient for our motor. The driver board uses four of these pairs, one for each motor coil.

ULN2003 Board Architecture

Pin Configuration Table:

Pin NameFunctionConnectionVoltage Level
IN1Coil A controlArduino Digital Pin5V logic
IN2Coil B controlArduino Digital Pin5V logic
IN3Coil C controlArduino Digital Pin5V logic
IN4Coil D controlArduino Digital Pin5V logic
VCC (+)Motor power supply5V power source4.5-5.5V
GND (-)Ground referenceCommon ground0V
Motor Connector5-pin JST28BYJ-48 motor plug

Additional Board Features:

Status LEDs: Four LEDs (one per coil) provide visual feedback showing which coils are energized during stepping. This is invaluable for debugging step sequences.

ON/OFF Jumper: A removable jumper allows you to disable motor power without disconnecting wires—useful for programming and testing.

Protection Diodes: Internal flyback diodes protect against back-EMF voltage spikes generated when coils de-energize.

Darlington Pair Explained

Understanding the Darlington configuration helps you appreciate why this simple driver works so well. Each Darlington pair consists of two NPN transistors connected such that the first transistor amplifies the Arduino’s low current signal, and the second transistor amplifies it again. This double-stage amplification provides current gain typically around 1000×.

Practical Result: A 20mA Arduino output can control 500mA motor current through a single Darlington pair.

Limitation to Know: Darlington pairs have a voltage drop of approximately 1.2-1.5V. This means when Arduino outputs 5V, the motor coil actually receives ~3.5V. For the 28BYJ-48, this reduction doesn’t significantly impact performance, but it’s why we need adequate supply voltage headroom.

28BYJ-48 ULN2003 Arduino Wiring Guide

Complete Connection Diagram

Step-by-Step Wiring Process:

1. Motor to Driver Connection: Simply plug the 28BYJ-48’s 5-pin connector into the matching socket on the ULN2003 board. The keyed connector prevents incorrect insertion—if it doesn’t fit easily, rotate 180°.

2. Driver Control Pins to Arduino:

ULN2003 PinArduino Uno PinWire Color (suggested)
IN1Digital Pin 8Red
IN2Digital Pin 9Orange
IN3Digital Pin 10Yellow
IN4Digital Pin 11Green

3. Power Connections:

This is the critical part where beginners often make mistakes.

Option A – External Power (Recommended):

5V Power Supply (+) → ULN2003 VCC

5V Power Supply (-) → ULN2003 GND AND Arduino GND

Arduino 5V → Not connected to driver

Option B – Arduino Power (Learning Only):

Arduino 5V → ULN2003 VCC

Arduino GND → ULN2003 GND

Power Supply Decision Tree

When you can use Arduino 5V:

  • Single motor operation
  • Short duty cycles (not continuous running)
  • Arduino powered by 9V wall adapter (not USB)
  • Educational testing only

When you MUST use external 5V:

  • Multiple motors
  • Continuous operation
  • Battery-powered Arduino
  • Production/permanent installations
  • Any USB-powered Arduino

Recommended External Power Sources:

Power SourceSpecificationsCostBest Use Case
5V 2A Wall Adapter5V DC, 2000mA$5-8Permanent installations
MB102 Breadboard PSUDual 5V/3.3V, 700mA$3-5Prototyping on breadboard
USB Power Bank5V, 1000-2400mA$8-15Portable/battery projects
4× AA Battery Holder6V nominal, step down to 5V$2-4Autonomous robots

Critical Rule: Arduino GND and external power supply GND must be connected together. This common ground reference is essential for the ULN2003 to correctly interpret Arduino’s control signals.

Programming 28BYJ-48 ULN2003 Arduino

Using the Built-In Stepper Library

Arduino IDE includes a Stepper library that handles the step sequencing for you. While limited in features, it’s perfect for understanding fundamental concepts.

Basic Control Code:

// 28BYJ-48 Stepper Motor Control – Arduino Stepper Library

// Accurately calibrated for 63.68395:1 gear ratio

#include <Stepper.h>

// Define accurate steps per revolution (32 steps × 63.68395 gear ratio)

const int stepsPerRevolution = 2038;

// Initialize stepper library

// Stepper(steps, pin1, pin3, pin2, pin4) – note the pin order!

Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {

  Serial.begin(9600);

  // Set motor speed in RPM (revolutions per minute)

  myStepper.setSpeed(10);  // 10 RPM = slow, smooth operation

  Serial.println(“28BYJ-48 Stepper Motor Ready”);

  Serial.println(“Steps per revolution: 2038 (accurate gear ratio)”);

}

void loop() {

  // Rotate one full revolution clockwise

  Serial.println(“Rotating clockwise – 1 revolution”);

  myStepper.step(stepsPerRevolution);

  delay(1000);

  // Rotate one full revolution counter-clockwise

  Serial.println(“Rotating counter-clockwise – 1 revolution”);

  myStepper.step(-stepsPerRevolution);

  delay(1000);

}

Understanding the Pin Order:

Notice the Stepper initialization uses pins in this sequence: 8, 10, 9, 11 instead of 8, 9, 10, 11. This specific order is required to match the motor’s internal coil activation sequence. The library needs coils energized in the pattern: Coil A → Coil C → Coil B → Coil D for proper rotation.

Speed Considerations

The setSpeed() function specifies motor speed in RPM (revolutions per minute). The 28BYJ-48’s mechanical limitations restrict maximum speed to approximately 12-15 RPM at 5V.

Practical Speed Guidelines:

Speed (RPM)Motor BehaviorBest Use Case
1-5 RPMVery smooth, quietPrecision positioning, clock movements
6-10 RPMSmooth, slight vibrationGeneral automation, camera sliders
11-15 RPMMaximum speed, noticeable vibrationFast repositioning (not continuous)
16+ RPMUnreliable, may skip stepsNot recommended

Advanced Control with AccelStepper Library

For production projects, I strongly recommend the AccelStepper library. It provides acceleration/deceleration, non-blocking operation, and multiple motor coordination.

Installation: Arduino IDE → Tools → Manage Libraries → Search “AccelStepper” → Install

AccelStepper Example Code:

// 28BYJ-48 with AccelStepper – Professional Control

#include <AccelStepper.h>

// Define motor pins

#define IN1 8

#define IN2 9

#define IN3 10

#define IN4 11

// Define accurate steps per revolution

#define STEPS_PER_REV 2038

// Create AccelStepper object

// AccelStepper::HALF4WIRE (4 wire, half step)

AccelStepper stepper(AccelStepper::HALF4WIRE, IN1, IN3, IN2, IN4);

void setup() {

  Serial.begin(9600);

  // Configure stepper performance

  stepper.setMaxSpeed(1000);       // Steps per second (not RPM!)

  stepper.setAcceleration(500);    // Steps per second^2

  stepper.setCurrentPosition(0);   // Set zero reference point

  Serial.println(“AccelStepper initialized”);

  Serial.println(“Half-step mode: 4076 steps/revolution”);

}

void loop() {

  // Move to position representing 2 full revolutions

  Serial.println(“Moving to position 4076 (1 revolution in half-step)”);

  stepper.moveTo(4076);  // Half-step mode doubles resolution

  // Run motor with smooth acceleration/deceleration

  while (stepper.distanceToGo() != 0) {

    stepper.run();  // This function must be called repeatedly

  }

  Serial.println(“Position reached!”);

  delay(1000);

  // Return to starting position

  Serial.println(“Returning to home position”);

  stepper.moveTo(0);

  while (stepper.distanceToGo() != 0) {

    stepper.run();

  }

  Serial.println(“Home position reached!”);

  delay(1000);

}

AccelStepper Advantages:

  1. Smooth Motion: Automatic acceleration prevents jerky starts and resonance issues
  2. Non-Blocking: Motor runs in background; Arduino can perform other tasks
  3. Position Tracking: Always knows current position relative to zero point
  4. Multiple Motors: Easily control 2+ steppers simultaneously
  5. Half-Step Mode: Doubles resolution to 4076 steps per revolution

Practical 28BYJ-48 ULN2003 Arduino Projects

Project 1: Automated Camera Slider

Hardware Requirements:

  • 28BYJ-48 motor with ULN2003 driver
  • GT2 timing belt and pulleys
  • Linear rail (400mm recommended)
  • Camera mount plate
  • Arduino Uno

Application: Time-lapse photography with smooth, repeatable camera movements.

Code Features:

  • Set slider travel distance in steps
  • Configure movement duration
  • Implement pause for shot capture
  • Return to start position

Project 2: Motorized Curtain Opener

Perfect weekend project for home automation.

Mechanical Setup:

  • Mount motor to curtain rail
  • Attach pulley to motor shaft
  • String connection to curtain

Control Options:

  • Time-based (open at sunrise, close at sunset)
  • Light sensor triggered
  • Remote control via IR sensor
  • Wi-Fi control with ESP8266 add-on

Project 3: Analog Clock Display

The 28BYJ-48’s precision makes it ideal for clock mechanisms.

Key Considerations:

  • Use 2038 steps (accurate gear ratio) for precise timekeeping
  • Account for cumulative error over extended operation
  • Implement periodic resynchronization
  • Battery backup to maintain position during power loss

Troubleshooting Common Issues

Problem 1: Motor Vibrates But Doesn’t Rotate

Symptoms: Motor hums/buzzes, LEDs flash, but shaft doesn’t turn.

Causes and Solutions:

CauseDiagnosticSolution
Incorrect wiringCheck LED patternVerify IN1-4 connections match code
Wrong step countMotor overshootsChange from 2048 to 2038 steps
Speed too highLoud buzzingReduce setSpeed() to 5-10 RPM
Insufficient powerArduino resetsUse external 5V power supply
Code using wrong pinsLEDs don’t light sequentiallyMatch code pins to physical wiring

Problem 2: Motor Runs One Direction Only

Root Cause: Step sequence inverted or pin order incorrect.

Fix: Reverse two of the motor coil connections or adjust pin order in Stepper() initialization.

Problem 3: Inconsistent Performance

Symptoms: Motor works sometimes, fails randomly, or loses position.

Diagnostic Steps:

  1. Measure supply voltage under load (should stay above 4.5V)
  2. Check for loose connections
  3. Verify common ground between Arduino and driver
  4. Test with fresh power supply (USB can be insufficient)

Problem 4: Motor Overheating

Analysis: The 28BYJ-48 normally runs warm (40-50°C) due to continuous coil energization. However, excessive heat (too hot to touch) indicates problems.

Solutions:

  • Verify motor is not mechanically binding
  • Reduce duty cycle (don’t run continuously)
  • Implement sleep mode when not stepping
  • Check for short circuits in wiring

Essential Resources and Downloads

Official Documentation

28BYJ-48 Datasheet:

  • Full electrical specifications
  • Mechanical drawings with dimensions
  • Performance curves
  • Download: Available from most supplier websites

ULN2003 IC Datasheet:

  • Texas Instruments official documentation
  • Current capacity specifications
  • Protection diode configuration
  • Download: TI Website – ULN2003A

Arduino Libraries

Stepper Library (Built-in):

  • Already installed with Arduino IDE
  • Location: File → Examples → Stepper
  • Documentation: arduino.cc/reference/en/libraries/stepper

AccelStepper Library:

Recommended Hardware Kits

Complete Starter Kits (typically $5-8):

  • 1× 28BYJ-48 motor (5V)
  • 1× ULN2003 driver board
  • Jumper wires
  • Available on Amazon, AliExpress, Adafruit

Quality Indicators:

  • Blue PCB driver boards (more reliable than green)
  • Clear LED indicators
  • JST connector properly soldered
  • Included mounting screws

Useful Online Tools

  1. Gear Ratio Calculator: Verify your motor’s actual step count
  2. RPM to Steps/Second Converter: Calculate AccelStepper speed values
  3. Arduino Pin Reference: Quick lookup for pin capabilities
  4. Breadboard Layout Tool: Plan your wiring before connecting

Frequently Asked Questions

1. Can I power the 28BYJ-48 motor directly from Arduino’s 5V pin?

Technically yes, but it’s not recommended for anything beyond initial testing. The motor draws approximately 200-240mA during operation, which is near the Arduino 5V regulator’s limit when powered via USB (typically 500mA total budget). If you’re powering Arduino through the barrel jack with a 9V/1A adapter, you have more current headroom, but it’s still marginal. For any continuous operation, multiple motors, or production use, always employ an external 5V power supply rated for at least 1A. The most common failure mode I see from beginners is inconsistent motor behavior, Arduino resets, and eventually damaging the Arduino’s voltage regulator by running motors directly from the 5V pin while USB-powered.

2. Why does my motor rotation count become inaccurate over time?

This cumulative positioning error typically stems from using the manufacturer’s claimed 2048 steps per revolution instead of the actual 2038 steps. Over many rotations, this 0.5% error accumulates significantly. For example, commanding 100 rotations using 2048 steps/rev means you’re actually commanding 204,800 steps, but the motor physically requires 203,800 steps for true 100 revolutions—you’ll overshoot by about half a revolution. The solution is simple: change your code to use 2038 steps per revolution (or 4076 for half-step mode). For ultra-precision applications like clock mechanisms, consider periodic recalibration against a reference position using a limit switch or optical sensor.

3. How do I control multiple 28BYJ-48 motors simultaneously with one Arduino?

Each motor requires its own ULN2003 driver board and four digital pins for control. Arduino Uno has 14 digital pins (pins 0-13), so theoretically you can control three motors (12 pins) while preserving pins 0 and 1 for Serial communication. Arduino Mega with 54 digital pins can control 13+ motors. For the power supply, calculate total current: each motor draws ~240mA, so three motors need approximately 720mA minimum, recommend 1.5A supply with safety margin. Use the AccelStepper library to coordinate multiple motors—it allows independent speed and position control while managing step sequences efficiently. Create separate AccelStepper objects for each motor with unique pin assignments.

4. What’s the difference between full-step and half-step modes?

Full-step mode energizes one coil at a time (or two coils simultaneously in some sequences), providing 2038 steps per revolution with the 28BYJ-48. Half-step mode alternates between single-coil and dual-coil energization, effectively doubling resolution to 4076 steps per revolution. The advantages of half-step mode include smoother motion with less vibration, finer positioning resolution, and reduced resonance at certain speeds. However, half-step mode provides slightly less holding torque (approximately 70% of full-step) because half the steps use only one coil instead of two. For most 28BYJ-48 applications, half-step mode is preferable due to the smoothness benefit. The AccelStepper library makes implementing half-step mode trivial—just specify AccelStepper::HALF4WIRE when creating the stepper object.

5. My motor works fine for a few minutes then stops responding. What’s wrong?

This classic symptom indicates thermal shutdown or power supply issues. The ULN2003 driver has internal thermal protection that disables output when the chip overheats (typically around 150°C junction temperature). This usually results from continuous high-current operation without adequate cooling or from operating above the motor’s rated voltage. First, verify you’re using 5V supply, not 6V or higher, as the motor is rated for 5V maximum. Second, ensure the driver board has airflow—placing it in an enclosed case without ventilation causes heat buildup. Third, if your application requires continuous operation, consider adding small heatsinks to the ULN2003 chip or implementing a duty cycle (run for a period, pause to cool, repeat). Finally, check your power supply’s actual voltage and current capacity under load with a multimeter—cheap power adapters often sag below their rated specifications.

Conclusion

The 28BYJ-48 ULN2003 Arduino combination represents the perfect entry point into stepper motor control. For under $3, you get a complete system that demonstrates fundamental motor control principles without the complexity and cost of industrial stepper solutions.

Throughout this guide, I’ve shared insights from years of PCB design experience, focusing on the practical details that make the difference between a frustrating experience and successful implementation. The key takeaways are straightforward: use the accurate 2038 steps per revolution, always employ proper power supply practices, and don’t hesitate to upgrade to the AccelStepper library for serious projects.

Remember that while this motor has limitations—relatively low speed, modest torque, and unipolar configuration reducing efficiency—these constraints actually make it better for learning. You’ll understand step sequencing, acceleration curves, and position tracking without getting overwhelmed by current limiting, microstepping configurations, or motor tuning parameters required by professional drivers.

Start with the basic Stepper library examples to understand fundamentals. Once comfortable, transition to AccelStepper for smoother motion and advanced features. Build simple projects first—a rotating platform, automated slider, or analog clock display. As your skills grow, you’ll know when it’s time to graduate to NEMA steppers with A4988 drivers for applications demanding higher torque and speed.

The 28BYJ-48 ULN2003 Arduino system will serve you well through your learning journey and remain useful for countless small automation projects. Its combination of affordability, simplicity, and adequate performance makes it an enduring favorite in the maker community, and understanding its operation provides a solid foundation for working with any stepper motor system.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.

  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.

Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.