EasyDriver + Stepper Motor with Arduino

Today was a busy shopping day in Deira, Dubai. Finally found a location where I can buy electronic stuffs like resistors, capacitors, LED etc. The things I bought today was

  • Regulated Power Supply
  • Soldering Station

Once I was home, I started to solder the EasyDriver Stepper Motor Driver.

Basically I soldered few male header so I can fix the EasyDriver board easily to a bread board. Then connected the Stepper Motor to the driver board and needed connection to Arduino board.

#define DIR_PIN 2
#define STEP_PIN 3

int rotation=0;
int direction = 1;
int ledYellowPin =  8;
int ledRedPin =  9;

void setup() {
  pinMode(DIR_PIN, OUTPUT);
  pinMode(STEP_PIN, OUTPUT);
  pinMode(ledYellowPin, OUTPUT);     
  pinMode(ledRedPin, OUTPUT);     
} 

void loop(){ 
  rotation++;
  if(rotation==10){
    direction = direction * -1;
    rotation = 0;
    digitalWrite(ledYellowPin, HIGH);
    digitalWrite(ledRedPin, HIGH);
    delay(1000);
    digitalWrite(ledYellowPin, LOW);
    digitalWrite(ledRedPin, LOW);
    delay(1000);
    digitalWrite(ledYellowPin, HIGH);
    digitalWrite(ledRedPin, HIGH);
    delay(1000);
    digitalWrite(ledYellowPin, LOW);
    digitalWrite(ledRedPin, LOW);
    delay(1000);
  }
  if(direction>0){
    digitalWrite(ledYellowPin, HIGH);
    digitalWrite(ledRedPin, LOW);
  }else{
    digitalWrite(ledYellowPin,LOW);
    digitalWrite(ledRedPin,  HIGH);
  }
  rotateDeg(direction * 360, 1.0);
}

void rotateDeg(float deg, float speed){
  int dir = (deg > 0)? HIGH:LOW;
  digitalWrite(DIR_PIN,dir); 
  int steps = abs(deg)*(1/0.225);
  float usDelay = (1/speed) * 70;
  for(int i=0; i < steps; i++){
    digitalWrite(STEP_PIN, HIGH);
    delayMicroseconds(usDelay); 
    digitalWrite(STEP_PIN, LOW);
    delayMicroseconds(usDelay);
  }
}

Reference: Use The EasyDriver Stepper Motor Driver + Arduino, Blink

By Imthiaz

Programmer, SAAS, CMS & CRM framework designer, Love Linux & Apple products, Currently addicted to mobile development & working @bluebeetle

4 comments

  1. hi bro……..can u tell me the location where in deira???? i want to buy arduino……

  2. Hi
    I lso live In Dubai, it wd be nic of you if you were a friend of mine In facebook
    FB://ameenahsan7@gmail.com

    So that You can help me find some electric stuff (arduino) 🙂

    055 6088344

  3. What’s the name of the shop,its location & contact details where you got your stepper motor & other electronic stuff?

Comments are closed.