int x;
void setup() {
pinMode(3,OUTPUT); // set Pin9 as PUL
pinMode(2,OUTPUT); // set Pin8 as DIR
}
void loop() {
digitalWrite(2,HIGH); // set high level direction
for(x = 0; x < 400; x++) // repeat 400 times a revolution when setting 400 on driver
{
digitalWrite(3,HIGH); // Output high
delayMicroseconds(500); // set rotate speed
digitalWrite(3,LOW); // Output low
delayMicroseconds(500); // set rotate speed
}
delay(1000); //pause 1 second
digitalWrite(2,LOW); // set high level direction
for(x = 0; x < 400; x++)
{
digitalWrite(3,HIGH);
delayMicroseconds(500);
digitalWrite(3,LOW);
delayMicroseconds(500);
}
delay(1000);
}