Connecting And Controlling The Stepper Motor In Motor Shield

Introduction

In this article, I will explain about connecting and controlling the Stepper motor in Motor Shield. It can be used to control the motor speed. and I have set the rotation time of the Stepper motor.
 
What is 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 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.

Battery

The battery is used to give power to the circuit, so only the circuit will work. It is also called an electronic device which produces the electrochemical cells.


Figure 3 - Battery

Connection

Step 1 - Connecting the Stepper Motor to Motor Shield

In the 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 dowload the library file and install to the Arduino.
Programming
  1. #include<AFMotor.h>  
  2. AF_Stepper motor(48,2);  
  3. Void step(){  
  4.    Serial.begin(9600);  
  5.    motor.setSpeed(10);  
  6. }  
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