const int DIR=4;
const int STEP=3;
const int steps_per_rev=200;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(STEP, OUTPUT);
pinMode(DIR, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(DIR, HIGH);
Serial.println("Spinning Clockwise.....");
for(int i=0;i<steps_per_rev;i++){
digitalWrite(STEP, HIGH);
delayMicroseconds(2000);
digitalWrite(STEP, LOW);
delayMicroseconds(2000);
}
delay(1000);
digitalWrite(DIR, LOW);
Serial.println("Spinning Anti-Clockwise.....");
for(int i=0; i<steps_per_rev;i++){
digitalWrite(STEP, HIGH);
delayMicroseconds(2000);
digitalWrite(STEP, LOW);
delayMicroseconds(2000);
}
delay(1000);
}