Internet of Things: Stepper Motor
Introduction
This chapter will discuss the connection and control of the stepper motor in Motor Shield in this chapter. This may be used for dc motor monitoring. And how to adjust the Stepper motor's rotation time.What is a Stepper Motor?
![](https://www.csharp.com/article/temp/56329/Images/stepper_motor.jpg)
Figure 1 - Stepper Motor
- Arduino Uno.
- Stepper Motor
- Motor Shield
- Battery.
Motor Shield
The Arduino Motor Shield is used to connect the full-bridge drive to the circuit. It is fully made up of 2 DC motors and includes load as the relay and stepper motor solenoids. We can also
measure the current of the motor.
Battery
The battery is used to give power to the circuit, so only the circuit will work. It is also called an electronic device that produces electrochemical cells.
Step 1 - Connecting the Stepper Motor to Motor Shield
In Stepper Motor, there are 5 pins and we have to connect 4 pins to the motor shield. We can leave the middle pin and connect all other 4 pins to the M3 and M4 while leaving the Gnd pin simply.
![](https://www.csharp.com/article/temp/56329/Images/ms.jpg)
Figure 2 - Motor Shield.
![](https://www.csharp.com/article/temp/56329/Images/Duracell_9_Volt_0849.jpg)
Figure 3 - Battery
Connection
Step 2 - Made InterConnect the Shield and the Arduino One by one.
![](https://www.csharp.com/article/temp/56329/Images/FQJBZSVH05NKJXO.MEDIUM.jpg)
Figure 4 - Motor and Arduino.
- Finally, connect the battery and upload the code to the Arduino Uno.
- Before including the Program, we have to download the library file and install it to the Arduino.
Programming
- #include<AFMotor.h>
- AF_Stepper motor(48,2);
- Void step(){
- Serial.begin(9600);
- motor.setSpeed(10);
- }
Explanation
- The Stepper motor can control the speed of the motor and it can be a single rotation forward and backward. It can take the step for every single rotation.
- "Single" means single-coil activation, "double" means 2 coils are activated at once (for higher torque) and "interleave" means that it alternates between single and double to get twice the resolution (but of course, it's half the speed).
- "Microstepping" is a method where the coils are PWM'd to create smooth motion between steps.
Figure 5 - Output
That’s all for this chapter. I hope you enjoyed reading!!
Author
Sr Karthiga
0
12.1k
2m