Internet of Things: Stepper Motor


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?

Stepper Motor is the DC motor so it moves in discrete steps. It can have many different sizes, speed controls, and positioning.
Figure 1 - Stepper Motor 
Parts Of Lists
  • 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.
Figure 2 - Motor Shield.
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.
Figure 3 - Battery


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.
Step 2 - Made InterConnect the Shield and the Arduino One by one.
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.
  1. #include<AFMotor.h>    
  2. AF_Stepper motor(48,2);    
  3. Void step(){    
  4.    Serial.begin(9600);    
  5.    motor.setSpeed(10);    
  6. }   
  • TheStepper 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 singlerotation.
  • "Single" means single-coil activation, "double" means2 coils are activated at once (for higher torque) and "interleave"means that it alternates between single and double to get twice theresolution (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!!
Sr Karthiga
211 12.1k 1.9m
Next » Internet of Things: Arduino