All posts
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
- Category
- Tags



Discussion
No comments yet