#define DIR_PIN 8
#define PUL_PIN 9
void setup(){
pinMode(PUL_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
}
void loop(){
// Initial direction
digitalWrite(DIR_PIN, HIGH);
for(int i=0;i<200;i++){
digitalWrite(PUL_PIN, HIGH);
delayMicroseconds(5000);
digitalWrite(PUL_PIN, LOW);
delayMicroseconds(5000);
}
delay(1000);
// Opposite direction
digitalWrite(DIR_PIN, LOW);
for(int i=0;i<200;i++){
digitalWrite(PUL_PIN, HIGH);
delayMicroseconds(5000);
digitalWrite(PUL_PIN, LOW);
delayMicroseconds(5000);
}
delay(1000);
}
/*
A4988 PINS
ENA o ---------- o MOTOR VCC
MS1 o o GROUND
MS2 o o 2B
MS3 o o 2A
RST o o 1A
SLP o o 1B
STP o o 5V
DIR o ---------- o GND
*/
12V