Stepper motors and Arduino motors 28BYJ-48 with ULN2003 driver

Ad Code

Stepper motors and Arduino motors 28BYJ-48 with ULN2003 driver

In this article, we will talk about stepper motors in Arduino projects using the very popular 28BYJ-48 model as an example. Just like servo drives, stepper motors are a critical element in automated systems and robotics. They can be found in many devices nearby, from a CD drive to a 3D printer or a robotic arm. In this article, you will find a description of the operation of stepper motors, an example of connecting to an Arduino using drivers based on ULN2003 and examples of sketches using the standard Stepper library.

Stepper motor - how it works

Stepper motor circuit

A stepper motor is a motor that moves its shaft depending on the steps and direction specified in the microcontroller program. Such devices are most often used in robotics, printers, manipulators, various machine tools and other electronic devices. The big advantage of stepper motors over constant rotation motors is that they provide accurate angular positioning of the rotor. Also, stepper motors have the ability to quickly start, stop, reverse.

The stepper motor rotates the rotor at a predetermined angle with an appropriate control signal. Thanks to this, it is possible to control the position of the units of the mechanisms and go to the specified position. The motor works as follows - in the central shaft there is a row of magnets and several coils. When power is applied, a magnetic field is created which acts on the magnets and causes the shaft to rotate. Parameters such as the angle of rotation (steps), the direction of movement are set in the program for the microcontroller.

Simplified animated diagrams of stepper motor operation

The main types of stepper motors:

Where to buy a stepper motor

The simplest engines Options on the AliExpress website:

Stepper motor Nema17 42BYGH 1.7A (17HS4401-S) for 3D printerSet of 5 ULN2003 28BYJ-48 Stepper Motors with Arduino Driver BoardsStepper Motor with 5V Stepper Motor Driver Module 28BYJ-48 + ULN2003
Another Stepper Motor Option for Arduino 28BYJ-48 5V 4 Phase DC Motor + ULN2003 Drive Test BoardSet of three stepper motors Nema17 Stepper Motor 42BYGH 1.7A (17HS4401) for 3D Product – 3D Printer Parts StepStick A4988 DRV8825 Stepper Motor Driver With Heat sink Carrier Reprap RAMPS 1.4 1.5 1.6 MKS GEN V1.4 board


Stepper motor driver

A driver is a device that links the controller and the stepper motor. The L298N and ULN2003 drivers are most commonly used to control a bipolar stepper motor.

Operating the motor in bipolar mode has several advantages:

But a significant disadvantage in bipolar mode is the complexity of the driver itself. The unipolar drive driver requires only 4 transistor switches; more complex circuitry is required for the bipolar drive driver to work. With each winding, various actions must be carried out separately - connecting to a power source, disconnecting. For such switching, a four-key bridge circuit is used.

Stepper motor driver based on L298N

This bridge driver controls a motor with a current of up to 2A and a supply of up to 46V. The module based on the L298N driver consists of an L298N microcircuit, a cooling system, terminal blocks, connectors for connecting signals, a voltage stabilizer and protective diodes.

L298N motor driver

Stepper motor driver ULN2003

Description of UNL2003 stepper motor driver

Stepper motors with ULN2003 based driver modules are frequent guests in Arduino workshops due to their cheapness and availability. As a rule, you have to pay for this with not very high reliability and accuracy.


Other drivers

There is another kind of driver - STEP / DIR drivers. These are hardware modules that use the STEP / DIR protocol to communicate with the microcontroller. STEP / DIR drivers expand the capabilities:

STEP / DIR drivers use 3 signals:

One of the most inexpensive STEP / DIR drivers is the TB6560-V2 module. This driver provides all the necessary functions and modes.

Connecting a stepper motor to Arduino

The connection will be considered using the example of the 28BYj-48 unipolar motor and the L298 and ULN2003 drivers. Arduino Uno will be used as a board.

Connecting a stepper motor to Arduino

Another variant of the circuit using the L298:

Connecting a stepper motor to Arduino based on L298

The connection diagram based on ULN2003 is shown in the figure below. The control outputs from the IN1-IN4 driver are connected to any digital contacts on the Arduino. In this case, digital pins 8-11 are used. Power is connected to 5V. It is also advisable to use a separate power source for the motor so that the Arduino board does not overheat.

Connecting a stepper motor to Arduino

Schematic connection diagram.

Schematic diagram of connecting a stepper motor

Another connection diagram for the Nema17 bipolar stepper motor through the L298 driver is as follows.

Overview of the main models of stepper motors for arduino

Nema 17 is a bipolar stepper motor that is most commonly used in 3D printers and CNC machines. The 170хHSхххА series of the motor is universal.

Main characteristics of the engine:

28BYJ-48 is a unipolar stepper motor. Used in small projects of robots, servo drives, radio-controlled devices.

Engine characteristics:

Description of the library for working with a stepper motor

In the Arduino IDE, there is a standard Strepper.h library for writing stepper motor programs. The main functions in this library are:

Example sketch for control

The set of examples of the Stepper.h library contains the stepper_oneRevolution program, in which all parameters for a stepper motor are set - the number of steps, speed, rotation.

#include <Stepper.h>

const int stepsPerRevolution = 200;

Stepper myStepper (stepsPerRevolution, 8,9,10,11); // connect to pins 8 ... 11 on Arduino

void setup() {

myStepper.setSpeed ​​(60); // setting the rotor speed



void loop() {

// The function waits for a command to come in, transforms the text and sends a signal to the motor to rotate it the specified number of steps.

Serial.println ("Move right"); //clockwise



Serial.println ("Move left"); //counterclock-wise





In this article, we learned what a stepper motor is, how you can connect it to an arduino, what a stepper motor driver is. We also looked at an example of writing a sketch using the built-in Stepper library. As you can see, there is nothing particularly difficult in working with stepper motors, and we recommend that you definitely experiment on your own and try to include it in your Arduino projects .

Close Menu