Hello friends, 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. But 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.
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
Unipolar
There are different types of motors depending on how the wires are connected to these. 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 l298 and l293. We can make a stepper driver circuit using these ICs.But it is very heavy work. We will use a stepper driver board to purchase to carry out this project.
Today stepper motor we use consists of five wires. It can be controlled via a stepper driver board. This can be controlled by four digital pins on the Arduino board. These four pins must be connected to the IN1, IN2, IN3, and IN4 pins on the drive board. This board should be connected to a 5 to 12 v supply. Ok, let’s do this project practically. The required components are as follows.
/*Stepper motor control.
*created by the SriTu 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);
}
We first need a library for this code. Put it into the Arduino IDE using the steps below.
#include <Stepper.h>
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);
}
Step 4
Select board and port.
Step 5
Upload this code and enjoy it.
The full video of this post is below. Please watch it. We will meet in the next post. Have a good day. Bye-bye.
Hello, welcome back. In this tutorial, we will learn how to make an IR remote control car using the Arduino. Also, the IR receiver module is mainly used to control…
Hello and welcome back. In this project, we will learn how to make a wifi control tank using the Nodemcu ESP8266 board with the Blynk application. For that, I used…
Arduino REED Switch Tutorial Hello guys, welcome back to my blog. This tutorial includes what is the Arduino Reed switch and how does works Arduino Reed switch. We can use…
Capacitive soil moisture sensor v1.2 Arduino code Hello guys, welcome back. Today we are going to talk about how the “capacitive soil moisture sensor ” works with Arduino….
Hello and welcome back. In this tutorial, we will learn How to make a Full Home Automation system using the Nodemcu board and the New Blynk app. This system includes…