const int DIR = 6;
const int STEP = 7;
const int steps_per_rev = 360;
void setup() {
Serial.begin(200000);
pinMode(STEP, OUTPUT);
pinMode(DIR, OUTPUT);
}
void loop() {
// To move the motor in the clockwise direction:
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);
// To move the motor in the anti-clockwise direction:
digitalWrite(DIR, LOW);
Serial.println("Spinning Anit-Clockwise...");
for(int i = 0; i < steps_per_rev; i++){
digitalWrite(STEP, HIGH);
delayMicroseconds(1000);
digitalWrite(STEP, LOW);
delayMicroseconds(1000);
}
delay(1000);
}