Creating stepper motor control program using Arduino UNO
Required Components
- Stepper Motor (NEMA17) -1 no
- A4988 Stepper Driver -1 no
- 12V 2A Adapter -1 no
- Arduino Board UNO or MEGA -1 no
- Connecting wires -1 set
Circuit
Steps
- Make sure the components are working properly.
- Connect the servo motor drive to the Arduino UNO.
- Connect the Servo motor to their driver circuit.
- Connect the external power source to the servo motor.
- Connect the Arduino pin 3&4 to driver circuit.
- Connect the +5v and ground(gnd) connections respectively.
- Check the Circuit Connections.
- Check the Arduino program.
- Run the Arduino program.
Arduino Program
#include <Stepper.h>
const int stepPin = 3;
const int dirPin = 4;
void setup( )
{
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
}
void loop( )
{
digitalWrite(dirPin,HIGH);
for(int x = 0; x < 200; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000);
digitalWrite(dirPin,LOW);
for(int x = 0; x < 400; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000);
}
Usage
- Packaging
- Industry automation
- Conveyer belt
Projects
- Robot arm
- Dustbin