The for-loop could it be like this?
{
digitalWrite(dirPin,HIGH);
for(int x = 0; x < 200; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
The StateChangeDetection I found on the pages of Arduino but I can't figure it out how to do it!