Arduino Projects

UniPolar and Bipolar Stepper Motors Speed and Position Control programming

Stepper Motor


Stepper Motors are used for precise positioning and that’s why they are used in Printers, CNC machines, CD ROMs, Robotics, Telescopes, toys and so on. There are mainly two types of Stepper motors

  1. UniPolar stepper Motors
  2. Bipolar stepper motors.

Unipolar  motors are further divided into two groups

  1. 5 wires UniPolar stepper motors
  2. 6 wires UniPolar stepper motors.

Bipolar motors come with 4 wires.

Regardless of the stepper motors type and size, the basic working concept of all stepper motors is exactly the same. In this guide, will teach you how to use the same programs to power all three stepper motors.

This post covers

  1. Constant speed and constant limits
  2. Variable speed and constant limits
  3. Precise manual positioning

The Amazon Purchase links are given below:

L298N motor driver:
12v UniPolar stepper motor:
CD ROM bipolar stepper motor:
24BYJ48 5V DC unipolar stepper motor:
Arduino Uno:
Mega 2560:
lm7805 Voltage Regulator:
330-ohm resistors pack:
female DC power jack socket:
470uf capacitors:
5×7 cm Vero board:
female headers:
connection wires:
Super Starter kit for Beginners:
Jumper Wires:
Bread Board:
12v Adaptor:
PCB plate:
Variable Supply:
Digital Multimeter:
Vero Board / stripboard:
Soldering iron kit: “best” You guys should definitely purchase this:
Solder wire:
Wire Stripper:
PCB small portable drill machine:


Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Circuit Diagram:

Stepper Motor

This is the full circuit diagram, built in the 9.1.0 edition of cadsoft eagle. As I said earlier, the basic working concept of all stepper motors is exactly the same regardless of the type and size of the  motors. As you can see on the screen, the circuit diagram will remain the same for all 3 stepper motors. Like the stepper motor,

use less than 4amps, so that’s why chose to use the L298N motor engine. The L298N motor driver is essentially designed to control simple dc motors; used this motor driver to power the robot in my previous tutorials  Since the L298N motor driver has the ability to control dc motors at the same time, and since you know that stepper motor has wires, this means that the l298N motor diver can control the unipolar and bipolar stepper motor. Okay, there’s no connection between the through wires. The unipolar connection is the same as the l298 engine as the bipolar connection As you can see in the circuit diagram, the stepper motor’s four wires are connected to the out1, out2, out3 and out4. While the motor driver’s input pins are attached to Arduino’s Pin number 8, 9, 10, and 11.

By definition, the l298n motor driver pins come with the jumper caps, so make sure you remove the jumper caps and attach the allow pins to pin number 6 and pin number 7 of the Arduino.

J1 is the DC female power jack, where we attach the 12v or 5v external power supply and eventually link the L298N motor driver’s VCC to the Arduino’s 5volts.

Let me tell you again if you use stepper motors with current ratings in excess of 4amps then never use the motor driver l298N. Now let’s look at the L298N motor driver’s pinout.

L2989N Motor Driver Pinout:

Stepper Motor

This is the dual H bridge operator of the L298N. With a peak current of up to 2amps, it motor driver can be used to  power Dc motors with voltages between 5 and 35volts. Since this is a dual HBridge motor driver, the speed and direction of two DC motors can be controlled simultaneously.

Since you have wires in stepper motor, this means that we can use the L298N motor driver to power one stepper motor. The motor coil wires of UniPolar and BiPolar Stepper are attached to the OUT1, OUT2, OUT3, and OUT4.

Let’s look at the L298N module pinout now, this module has three terminal blocks, two-terminal blocks are marked with OUT1, OUT2, OUT3, and OUT4. 

This is where the Stepper Motor wires are connected.

Stepper Motor

It block is labelled with + 12v, GND, and + 5v. The external power supply is connected to the contacts of + 12v and GND. This doesn’t matter if we always connect 12 volts, it depends on the Stepper motor’s voltage level.

You can attach a 5 volt power supply to the + 12v and GND contacts if you are using a 5v Stepper motor. I will be using a 12-volt power supply and a 5-volt power supply in this article. The touch of + 5 volts is connected to the 5 volts of the Arduino.

Stepper Motor

As you can see, this motor driver also has some male headers and ENA, IN1, IN2, IN3, IN4, and ENB are clearly labeled. To allow both the engines, the ENA and the ENB are used. Jumper caps ensures all engines are permitted by default and the engines spin at full speed.

If the jumper caps are removed and the ENA and ENB pins connected to the Arduino PWM pins, the frequency of the motors can be controlled by modulation of the pulse width.

But we don’t use Pulse Width Modulation in this tutorial. We will only use the appropriate pins to turn the stepper motors on and off. In the circuit diagram, the relations are already clarified.

Stepper Motor Programming:

Stepper Motors Program 1:

Stepper Motors Program number 2:

Stepper Motors Program 3:

Watch Video Tutorial

Related Articles

Leave a Reply

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

Back to top button