Introduction: Stepper Motor Control With Arduino.

About: I hold a Master's degree in Computer Science and currently teach STEM and ICT. My focus is on making technology and engineering concepts accessible to students through hands-on projects. I teach topics like ro…

Welcome back to my blog. Today we are going to talk about a motor control topic. In a previous post, we explained how to control a servo motor. Read it using this link Servo motor. So, let’s look at the topic today.

What is a stepper motor?


When we take a typical DC motor, we can get two functions out of it. These include changing the direction of rotation by changing the anode and cathode and changing the supply potential to control the speed of the motor. However, these motors cannot control the steps and volume of rotation. For that, we can use stepper motors. With these stepper motors, we can control the turning steps. See the picture below.

Stepper motor control with Arduino.


It has two coils. We can rotate this motor according to the pattern that supplies power to these coils. We can see a large number of stepper motors and the two main types are depending on the way the coils are wrapped.

Bipolar

Stepper motor control with Arduino.

Unipolar

Stepper motor control with Arduino.

There are different types of motors depending on how the wires are connected to them. The bipolar types of motors have four wires. Other stepper motors have wires 4,5,6 etc. This type of motor cannot be controlled by supplying power in the normal way. This requires a special circuit. That is, an H-bridge circuit must be used. This circuit has four transistors. I described the H-Bridge circuit in a previous post. Click this link and read it Click me. There are two main types of ICs that contain these h-bridges. Those are l298N and l293D. We can make a stepper driver circuit using these ICs.But it is very heavy work. We will use a stepper driver board to carry out this project.

Supplies

  1. Arduino Uno board
  2. Stepper motor and driver board
  3. Jumper wires

Step 1: Identify the Components

Step 2:


Connect these components using the circuit diagram below.



Step 3:

Step 3

Let’s look at the code below.

  1. The complete program of this project –
/*Stepper motor control.
*created by the Zorro Tech team.
*Read the code below and use it for any of your creations
*/

#include <Stepper.h>
#define STEPS 100
Stepper stepper(STEPS, 8, 9, 10, 11);
void setup() {
stepper.setSpeed(200);//set motor speed
}
void loop() {
stepper.step(200);
delay(1000);//delay
stepper.step(200);
}

For this code, you need to add a stepper library file. Put it into the Arduino IDE using the steps below.

This code specifies the number of steps required to rotate the motor.

#define STEPS 100

This code includes the digital PINs used and the number of steps.

Stepper stepper(STEPS, 8, 9, 10, 11);

The code in the void setup controls the speed of the motor.

void setup() {
stepper.setSpeed(200);//set motor speed
}

This code causes the motor to rotate. Change its values ​​and try again.

void loop() {
stepper.step(200);
delay(1000);//delay
stepper.step(200);
}

Now, you can test this project.

Have a good day.