
Stepper motors are widely used in various applications requiring precise control of angular position, speed, and acceleration. They differ from regular DC motors in that they divide a full rotation into a series of discrete steps, allowing for very accurate positioning. Commonly used in robotics, CNC machines, and 3D printers, stepper motors can be controlled using simple electronics, and one of the most popular platforms for controlling them is Arduino.
In this guide, we’ll explore how to control different types of stepper motors using both unipolar and bipolar circuits with an Arduino. We’ll also cover the basics of stepper motors, their driving circuits, and how to interface them with an Arduino.
Understanding Stepper Motors
Stepper motors, due to their unique design, can be controlled to a high degree of accuracy without any feedback mechanisms. The shaft of a stepper, mounted with a series of magnets, is controlled by a series of electromagnetic coils that are charged positively and negatively in a specific sequence, precisely moving it forward or backward in small "steps".
There are two types of steppers, Unipolars and Bipolars, and it is very important to know which type you are working with. For each of the motors, there is a different circuit. The example code will control both kinds of motors. See the unipolar and bipolar motor schematics for information on how to wire up your motor.
The stepper is controlled by with digital pins 8, 9, 10, and 11 for either unipolar or bipolar motors. The Arduino board will connect to a U2004 Darlington Array if you're using a unipolar stepper or a SN754410NE H-Bridge if you have a bipolar motor.
Before diving into the circuits and control methods, it’s essential to understand the two primary types of stepper motors: unipolar and bipolar.

1. Unipolar Stepper Motors: Unipolar stepper motors have two coils per phase, and each coil has a center tap. This allows each coil to be powered in one direction, simplifying the driving circuitry. Since you have a center tap on each coil, you only need to control the switching of the power between the coils, making the control logic simpler and less complex.

2. Bipolar Stepper Motors: Bipolar stepper motors have only one coil per phase, but unlike unipolar motors, they do not have a center tap. This means you need to reverse the current in each coil to change the direction of the magnetic field, which requires a more complex driving circuit.
Components Needed
To control a stepper motor with an Arduino, you’ll need the following components:
• Arduino Board (e.g., Uno, Nano, etc.)
• Stepper Motor (Unipolar or Bipolar)
• Motor Driver IC (ULN2003 for unipolar motors, L298N or A4988 for bipolar motors)
• External Power Supply (for powering the stepper motor)
• Jumper Wires
• Breadboard
Controlling a Unipolar Stepper Motor
Unipolar stepper motors are relatively easy to control. Let’s first look at how to control a typical unipolar stepper motor with the ULN2003 driver.
Circuit Setup
1. Connect the Stepper Motor:
The unipolar stepper motor will have 5 or 6 wires. Two of these are for the power supply, and the remaining are for the coils. Typically, you will have 4 coils, each with a center tap. The center taps are connected to a power source, and the four other leads go to the ULN2003 driver.
2. Connect the ULN2003 Driver to Arduino:
• Connect the IN1, IN2, IN3, and IN4 pins on the ULN2003 driver to the Arduino digital pins (e.g., pins 8, 9, 10, and 11).
• The common pin (COM) on the ULN2003 should be connected to a 5V or 12V power source, depending on your motor’s requirements.
• The OUT pins of the ULN2003 driver are connected to the motor coils.
• Connect the ground (GND) of the ULN2003 to the Arduino ground.
Code for Controlling a Unipolar Stepper Motor
This basic code makes the motor rotate forward and backward in discrete steps. You can adjust the stepsPerRevolution variable based on your specific stepper motor.
Controlling a Bipolar Stepper Motor
Controlling a bipolar stepper motor requires a more complex setup due to the need to reverse current direction in the motor coils. The L298N or A4988 driver ICs are commonly used for bipolar stepper motors.
Circuit Setup for Bipolar Stepper Motor with L298N
1. Connect the Stepper Motor:
A bipolar stepper motor has two pairs of wires for the coils. These wires should be connected to the OUT1, OUT2, OUT3, and OUT4 pins of the L298N driver.
2. Connect the L298N to Arduino:
• Connect the IN1, IN2, IN3, and IN4 pins on the L298N driver to the Arduino digital pins (e.g., pins 8, 9, 10, and 11).
• Connect the ENA and ENB pins of the L298N to 5V.
• The VCC and GND pins of the L298N are connected to the external power supply (12V or whatever voltage suits your motor).
Code for Controlling a Bipolar Stepper Motor
Conclusion
Controlling stepper motors with Arduino is an excellent way to learn about motor control and precise positioning. Whether you're using a unipolar or bipolar stepper motor, the process can be simplified with the right driver circuit, like the ULN2003 or L298N.
By understanding the differences between unipolar and bipolar motors, you can select the appropriate motor for your project and control it with ease using Arduino. The flexibility of Arduino makes it an ideal platform for experimenting with various types of stepper motors in DIY robotics, automation, and other precision-based applications.
With this basic knowledge, you can extend the code and hardware to build more advanced control systems, such as variable speed control, microstepping, or integrating stepper motors into larger systems like CNC machines or 3D printers.
Happy building!
Written by Icey Ye from AIChipLink.
AIChipLink, one of the fastest-growing global independent electronic component distributors in the world, offers millions of products from thousands of manufacturers. Whether you need assistance finding the right part or electronic components manufacturers for your design, you can contact us via phone, chat or e-mail. Our support team will answer your inquiries within 24 hours.







