#define A 2
#define _A 3
#define B 4
#define _B 5
void setup() {
pinMode(A, OUTPUT);
pinMode(_A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(_B, OUTPUT);
Serial.begin(115200);
// MoveForward(4,10);
// delay(1000);
// MoveBackward(4,10);
for(int i=1;i<=109;i++){FourSteps();delay(100);}
}
void loop() {
// MoveBackward(4,10);
// delay(500);
// MoveForward(4,10);
// delay(500);
//delay(1000);
// for(int i=4;i>=0;i--){FourSteps(i);delay(100);}FourSteps(4);
// delay(1000);
}
int i;
void FourSteps(bool a=0){
if(!a)i++;
Serial.print("Step = ");
Serial.println(i);
switch (i){
case 1:
digitalWrite(A, HIGH);
digitalWrite(_A, LOW);
digitalWrite(B, LOW);
digitalWrite(_B, LOW);
break;
case 2:
digitalWrite(A, LOW);
digitalWrite(_A, LOW);
digitalWrite(B, HIGH);
digitalWrite(_B, LOW);
break;
case 3:
digitalWrite(A, LOW);
digitalWrite(_A, HIGH);
digitalWrite(B, LOW);
digitalWrite(_B, LOW);
break;
case 4:
digitalWrite(A, LOW);
digitalWrite(_A, LOW);
digitalWrite(B, LOW);
digitalWrite(_B, HIGH);
if(!a)i=0;
break;
}
}