Arduino Tutorials – Lesson 21 – Stepper motor control Using Arduino UNO

Creating stepper motor control program using Arduino UNO

Required Components

  1. Stepper Motor (NEMA17) -1 no
  2. A4988 Stepper Driver -1 no
  3. 12V 2A Adapter -1 no
  4. Arduino Board UNO or MEGA -1 no
  5. Connecting wires -1 set

Circuit

Steps

  1. Make sure the components are working properly.
  2. Connect the servo motor drive to the Arduino UNO.
  3. Connect the Servo motor to their driver circuit.
  4. Connect the external power source to the servo motor.
  5. Connect the Arduino pin 3&4 to driver circuit.
  6. Connect the +5v and ground(gnd) connections respectively.
  7. Check the Circuit Connections.
  8. Check the Arduino program.
  9. 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

  1. Packaging
  2. Industry automation
  3. Conveyer belt

Projects

  1. Robot arm
  2. Dustbin

Leave a Reply

Your email address will not be published. Required fields are marked *