Stepper motors are widely used in precision control applications such as 3D printers, CNC machines, camera sliders, and robotics. One of the most affordable and commonly used stepper motors among hobbyists and electronics learners is the 28BYJ-48, usually paired with the ULN2003 driver module. In this article, we’ll dive into the fundamentals of stepper motors, the 28BYJ-48 motor, and how to control it using Arduino.
How Does a Stepper Motor Work?A stepper motor is a brushless DC motor that moves in discrete steps. Unlike regular DC motors, which rotate continuously, a stepper motor rotates in defined increments called steps. Each pulse sent to the motor results in the motor shaft moving by one fixed angle. This allows for precise position control without feedback (open-loop control).
Stepper motors can be driven in various stepping modes. Each mode determines how coils are energized and how much the shaft rotates per step.
1. Full Step Mode (Single Phase ON) or Wave SteppingIn this mode, only one winding is energized at a time. It consumes less power but produces less torque. The motor moves one step at a time with a relatively lower holding torque.
2. Full Step Mode (Two Phase ON)Here, two windings are energized simultaneously. This results in better torque compared to the single-phase mode. It’s commonly used when higher holding torque is required.
3. Half Step ModeThis mode alternates between single and double coil excitation, effectively doubling the step resolution. It gives a smoother rotation and better positioning. For example, a motor that has 64 steps per revolution in full-step mode will have 128 steps per revolution in half-step mode.
4. Microstepping ModeIn microstepping, the current through the motor coils is controlled in finer increments, allowing very smooth and precise motion. It’s used in applications where minimal vibration and high resolution are required. However, this mode typically requires more complex drivers than ULN2003.
Types of Stepper MotorsThere are three main types of stepper motors
- Permanent Magnet Stepper (PM) – Low cost, suitable for low-resolution applications.
- Variable Reluctance Stepper (VR) – Simple construction, less commonly used.
- Hybrid Stepper – Combines features of both PM and VR, offers high torque and precision.
The 28BYJ-48 is a Permanent Magnet stepper motor, ideal for light-duty applications.
Introduction to 28BYJ-48 Stepper MotorThe 28BYJ-48 is a 5V unipolar stepper motor often found in consumer electronics. It is cost-effective, compact, and provides precise movement, making it ideal for prototyping and educational projects.
28BYJ-48 Stepper Motor Specifications- Rated Voltage: 5V DC
- Number of Phases: 4
- Step Angle: 5.625°/64
- Gear Ratio: 1:64
- Operating Current: ~240mA
- Steps Per Revolution: 32 steps/rev × 64 gear ratio = 2048 steps/rev
This high step count provides excellent positioning precision.
28BYJ-48 Stepper Motor PinoutThe motor has a 5-wire connector:
- Red – VCC (Common for all coils)
- Blue – Coil 1
- Pink – Coil 2
- Yellow – Coil 3
- Orange – Coil 4
These wires connect directly to the ULN2003 driver board.
ULN2003 Stepper Motor Driver ModuleThe ULN2003 module is a popular driver board used to control the 28BYJ-48 stepper motor. It uses a ULN2003A Darlington transistor array, which allows the Arduino to switch the motor coils without overloading its pins.
Key Features:- LED indicators for each channel to visualize activity
- Motor connector for plug-and-play compatibility with 28BYJ-48
- Input headers for easy connection to Arduino
- Onboard power supply terminal for motor VCC
- IN1 to IN4 – Control inputs from Arduino
- GND – Ground
- VCC – 5V supply to motor
- Motor Connector – Connects to 28BYJ-48 stepper motor
- Power LED – Indicates module is powered
- Step LEDs – Show step pulses being sent to motor
Arduino Example Code
In the following code, we will be rotating the stepper motor in the clockwise and anti-clockwise direction.
/*
Interfacing Stepper Motor with Arduino UNO using Stepper Library using ULN 2003 Motor driver board by www.playwithcircuit.com
*/
#include <Stepper.h>
//define Input pins of the Motor
#define OUTPUT1 7 // Connected to the Blue coloured wire
#define OUTPUT2 6 // Connected to the Pink coloured wire
#define OUTPUT3 5 // Connected to the Yellow coloured wire
#define OUTPUT4 4 // Connected to the Orange coloured wire
// Define the number of steps per rotation
const int stepsPerRotation = 2048; // 28BYJ-48 has 2048 steps per rotation in full step mode as given in data sheet
// Initialize the stepper motor with the sequence of control pins OUTPUT1, OUTPUT3, OUTPUT2, IN4
// OUTPUT1 and OUTPUT3 are connected to one coil and OUTPUT2 and OUTPUT4 are connected to one Coil
Stepper myStepper(stepsPerRotation, OUTPUT1, OUTPUT3, OUTPUT2, OUTPUT4);
void setup() {
// Set the speed of the motor in RPM (adjust as needed)
myStepper.setSpeed(15); // 15 RPM
}
void loop() {
// Rotate in One Direction and complete one complete rotation i.e 2048 steps
myStepper.step(stepsPerRotation);
delay(1000); // Delay between rotations
// For Rotation in opposite direction provide the variable to the parameter with negative Sign
myStepper.step(-stepsPerRotation);
delay(1000); // Delay between rotations
}
👉 For complete article, code, and step-by-step guide, check out the full tutorial Controlling 28BYJ-48 Stepper Motor with Arduino
Comments
Please log in or sign up to comment.