Interfacing 28BYJ-48 Stepper Motor with Arduino Uno

Stepper motors are widely used in projects that require accurate and repeatable motion control. Unlike conventional motors that rotate continuously, stepper motors move in fixed increments, making them ideal for applications such as robotics, CNC systems, and automated devices.

In this project, we explore how to control a popular 28BYJ-48 stepper motor using a driver module and an Arduino Uno. This setup allows precise control over direction and speed, making it a great starting point for beginners learning motion control systems.

 

How Does a Stepper Motor Work?

A stepper motor is a type of brushless motor designed for precise position control. Instead of rotating continuously like a DC motor, it moves in small, fixed angular steps. This behavior is achieved using electromagnetism, where the stator contains multiple coils and the rotor typically has permanent magnets.

When a specific coil is energized, it creates a magnetic field that attracts the rotor into alignment. By activating the coils one after another in a defined sequence, the rotor advances step by step. Reversing this sequence changes the direction of rotation. Because each electrical pulse corresponds to a movement step, microcontrollers can easily control position, speed, and direction with high accuracy.

 

Modes of Operation in Stepper Motor

Stepper motors can be driven using different stepping techniques depending on the required balance between torque, smoothness, and precision.

▪ Full Step Mode (Single Phase ON) or Wave Stepping

In this method, only one coil is powered at any given time. The motor advances one full step per signal. This approach is energy-efficient and generates less heat, but it produces lower torque, making it suitable for light-load applications.

▪ Full Step Mode (Two Phase ON)

Here, two coils are energized simultaneously. This increases the magnetic force, resulting in higher torque output. However, this comes with slightly higher power consumption and can introduce minor vibrations during operation.

▪ Half Step Mode

Half stepping alternates between single-coil and dual-coil activation. This effectively doubles the number of steps per rotation, leading to smoother motion and improved positioning accuracy. It is commonly used when both precision and moderate torque are required.

▪ Microstepping Mode

Microstepping further refines motion by controlling the current supplied to each coil. Instead of switching coils fully on or off, the current is varied gradually. This allows extremely fine positioning, reduced noise, and smoother operation, making it ideal for precision systems like CNC and 3D printing.

 

Introduction to 28BYJ-48 Stepper Motor

The 28BYJ-48 is a compact and economical stepper motor widely used in DIY electronics projects. It operates at 5V and includes an internal gear reduction mechanism, which improves torque while reducing speed. This makes it particularly suitable for applications where controlled and steady movement is required.

One of its key characteristics is the five-wire interface, where four wires control the motor coils and one serves as a common connection. By applying signals in the correct order, the motor can rotate precisely in both directions.

 

The 28BYJ-48 motor is designed for low-power applications and typically operates at 5V. It features a built-in gear ratio that enhances torque output, making it capable of handling small mechanical loads. The step angle is reduced due to the gearbox, allowing finer control over rotation. Its low cost and ease of interfacing make it a popular choice for beginners.

 

28BYJ-48 Stepper Motor Pinout

This motor consists of five wires: one common power line and four control lines connected to individual coils. The common wire is usually connected to the positive supply, while the remaining wires are driven in sequence to create rotational movement. Each wire corresponds to a specific coil inside the motor, and energizing them in order determines the direction and stepping behavior.

 

ULN2003 Stepper Motor Driver Module

Stepper motors require more current than a microcontroller can safely provide. To handle this, a driver module like the ULN2003 is used as an interface between the motor and the controller.

The ULN2003 contains multiple Darlington transistor pairs that amplify current, allowing it to drive the motor coils efficiently. It also provides basic protection to the control circuit while ensuring reliable switching of the motor phases.

 

ULN2003 Module Pinout

The ULN2003 driver board includes input pins (IN1 to IN4) that receive control signals from the microcontroller. These inputs determine which motor coils are energized. The module also includes power and ground connections, along with a dedicated connector for the stepper motor.

An external 5V supply is typically recommended to power the motor, as it ensures stable performance without overloading the microcontroller. The onboard indicators help visualize the active phases during operation.

 

Interfacing 28BYJ-48 Stepper Motor with Arduino Uno

 

Components Required

 

  • 28BYJ-48 Stepper Motor
  • ULN2003 Driver Module
  • Arduino Uno
  • Jumper Wires
  • Breadboard (optional for prototyping)
  • USB Cable for Arduino
  • 5V External Power Supply

Connecting the system is straightforward and beginner-friendly. The control inputs of the ULN2003 driver are linked to digital pins of the Arduino Uno, allowing it to send step sequences. The motor plugs directly into the driver module, eliminating complex wiring.

A separate 5V power source is connected to the driver to supply sufficient current for the motor. It is important to ensure that the ground of the power supply and the Arduino are common, so signals are referenced correctly.

Once the hardware is set up, the Arduino can generate pulse sequences to control rotation direction and speed. By adjusting the sequence and timing, different stepping modes can be implemented for various applications.

 

Arduino Example Code

 

In the code below, we will rotate the stepper motor in the clockwise and anti-clockwise direction, one complete rotation in both the directions. We will be using the Stepper library by Arduino.

 

CODE
/* 
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
}

Stepper motors offer a simple yet powerful way to achieve precise motion control in embedded systems. With the help of a driver module and a microcontroller, even beginners can build reliable motion-based projects. The 28BYJ-48 motor, combined with the ULN2003 driver, provides an accessible starting point for learning about controlled movement and automation.

To learn how to drive a stepper motor in different modes, check the full guide here: https://playwithcircuit.com/water-level-sensor-arduino-tutorial/

License
All Rights
Reserved
licensBg
0