28BYJ-48 Arduino- How to Program the 28BYJ-48 in 3 Different Ways

Stepper motors make up the bulk of our electronics; therefore, an experiment with a 28byj-48 Arduino can help us understand the operation of these devices.  We’re discussing electronics such as security cameras, 3D printers, and …

28BYJ-48 Arduino

Stepper motors make up the bulk of our electronics; therefore, an experiment with a 28byj-48 Arduino can help us understand the operation of these devices. 

We’re discussing electronics such as security cameras, 3D printers, and DVD players.

 This article will discuss how to interface one of the commonest stepper motors with Arduino.

Also, learn the main libraries you need on Arduino to control this motor. 

Table of Contents

What is a Stepper Motor

An electrical stepper motor. 

An electrical stepper motor. 

They are primarily brushless DC electric motors that rotate in precise and discrete steps to create a uniform angular rotation.

Each of the motors features coils that, upon applying an electrical current, are energized to rotate uniformly to produce stepwise increments in rotation. 

Therefore stepper motors can generate incremental rotational steps, a feature that makes them rotate seamlessly without necessarily requiring a position sensor.

The property further ensures that they rotate at a uniform speed and positional accuracy. 

The 28BYJ-48 Stepper Motor

An Electric Stepper Motor. 

An Electric Stepper Motor. 

It is typically a 5-wire unipolar stepper motor that you can use in projects that require functionalities such as precise positioning and vent control.

Since it’s a stepper motor, it is brushless, meaning its precision during movement is top-notch. 

This motor uses a 5V power supply, and despite being relatively miniature, it can create 34.3 mN.m torque at a relative speed of 15 RPM.

You can also rely on it to provide exquisite torque even while it’s in a standstill position as long as you’ve connected it to power. 

Nonetheless, the above feature is a downside as it means the stepper motor consumes power even while in a standstill position. 

28BYJ-48 Stepper Motor Specifications

A disassembled stepper motor. 

A disassembled stepper motor. 

The table below gives the rating and specifications of this stepper motor. 

Feature28BYJ-48 Stepper Motor Spec
Size and DimensionRound-shaped with a 28mm diameter
Shaft typeFlatted Shaft
Coil TypeUnipolar
Rated Voltage5V
Coil Resistance50 Ohms
Gear Reduction1/64
No. of phase4 Phases
Step AngleFull step mode – 0.176°Half-step mode – 0.0879°
Motor TypePermanent Magnet Gear Motor
Mounting Hole SpacingFlatted Shaft

28BYJ-48 Stepper Motor Pinout

DC Electric Motors

DC Electric Motors

The stepper motor features five wires, four coils, and a center tap.

The latter is a 5V power supply pin.

Notably, each of the coils and the center tap creates a phase. 

Therefore, as we asserted in the specifications table, the stepper motor features 4 phases. 

The ULN2003 Driver Board

The ULN2003 is the module we primarily use to control the 28BYJ-48 stepper motor.

So what exactly makes up the module? 

At its core is a Darlington array chip of transistors that come as one package, thus eliminating the essence of packing multiple individual NPN transistors.

Below is an elaboration on how to connect it to Arduino. 

ULN2003 Driver Board pinArduino Pins
IN pins (1 to 4)Pins 8 to 11
VCC Pin5V pin
GND PinGND Pin

During its operation, the prerequisite for current flow through the motor is that the driver’s digital pins 8 to 11 must be on the HIGH phase.

Also, you must include a metal jumper in the connection between the stepper motor and the 5V power supply. 

Otherwise, no current will reach your stepper motor without this metal jumper. 

Moreover, some LEDs aid in visualizing the various motor steps in the driver module.

But you may only note this during operation if the motor is moving at relatively low speeds. 

How to Interface 28byj-48 with Arduino

A Simple Arduino Uno board

A Simple Arduino Uno board

Now, let’s explore how to connect the Arduino Uno board, the ULN2003 Driver board, and the 28BYJ-48 stepper motor

Components Required

Assemble the following parts:

  • A 28BJY-48 Stepper motor
  • A USB cable
  • An Arduino Uno board
  • Arduino IDE
  • ULN2003 driver
  • Several Male to female jumper wires (about 6)

Wiring the connection

Earlier, we captured how to connect the ULN2003 Driver Board to Arduino Uno.

So make the connections as highlighted and connect the stepper motor to the driver as per the diagram below. 

Lastly, you must ensure that the Arduino and the circuit have a common ground. 

Using Built-in Stepper Library

With everything set, uploading the first sketch to the IDE is time.

We’ll start by running the built-in Stepper library on the Arduino IDE’s repository.

The upside of applying this library is that its imperative in controlling the stepping sequence of your motor. 

It is also imperative in monitoring and controlling a wide range of motors- including: 

  • Unipolar stepper motors 
  • Bipolar stepper motors

So without further ado, let us explore a sketch you can use to control the motor’s rotation in one direction and shift it to the other direction. 

Using the AccelStepper Library

You should use the built-in stepper Library for single-motor experiments.

But for slightly more sophisticated projects, such as those required to control numerous stepper motors, the AccelStepper library is the best. 

It is an advanced form of the erstwhile library we covered and comes with many benefits, including enabling acceleration and deceleration of the stepper motor.

With the AccelStepper library, you can also perform half-step driving.

Lastly, it allows you to run multiple steppers at a go.

Nonetheless, it is unavailable on your IDE, so you must download it first. 

Library Installation Process

Select, then allow your library manager to update its available libraries. 

Search the AccelStepper library from the results and select install.

Next, we’ll give you the Arduino code for this library and give you a glimpse of the functionalities it grants. 

As mentioned, this library offers more functionalities than the built-in stepper motor.

For instance, it can accelerate your stepper motor and then enable deceleration.

Then the motor spins in the opposite direction after completing the initial rotation. 

Control Two 28BYJ-48 Stepper Motors Simultaneously

Is it possible to run two stepper motors at the same time?

It is impossible with the above two setups, but we can modify the above code and set up the circuit differently to allow the functionality. 

First, you need to alter the order of your connection, as now you’ll be including a second stepper motor.

Check out the diagram below for the new connection. 

Next, you need to upload the sketch below. It will move one of the motors in one full-step mode during acceleration.

As this motor decelerates, the other motor moves in a half-step mode. The motor’s direction will shift in the next revolution. 

Applications of a 28BYJ-48 Stepper Motor

A CNC Laser Cutting machine. 

A CNC Laser Cutting machine

Here are some gadgets where you’ll likely find this stepper motor. 

Summary

Above is a detailed explanation of how to set up the 28BYJ-48 and interface it with Arduino.

From the codes we’ve provided, you’ve noted that you can set up the stepper motor to perform different operations.

You must include the instructions in the respective sketch you need to use.

But remember to follow the Arduino syntax for your code to work.

All the best as you set out to create your project with this stepper motor. 

Categories How