OK modified the code to
[code]int E1 = 6;
int E2 = 5;
int M1 = 8;
int M2 = 7;
void setup()
{
int i;
for(i=5;i<=8;i++)
pinMode(i, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int leftspeed = 255;
int rightspeed = 255;
analogWrite (E1,leftspeed); // forward
digitalWrite(M1,LOW);
analogWrite (E2,rightspeed);
digitalWrite(M2,LOW);
delay(1000);
digitalWrite(E1,LOW);
digitalWrite(E2,LOW);
delay(1000); // A small pause to allow the motors to stop
analogWrite (E1,leftspeed); // right
digitalWrite(M1,LOW);
analogWrite (E2,rightspeed);
digitalWrite(M2,HIGH);
delay(1000);
digitalWrite(E1,LOW);
digitalWrite(E2,LOW);
delay(1000); // A small pause to allow the motors to stop
analogWrite (E1,leftspeed); // left
digitalWrite(M1,HIGH);
analogWrite (E2,rightspeed);
digitalWrite(M2,LOW);
delay(1000);
digitalWrite(E1,LOW);
digitalWrite(E2,LOW);
delay(1000); // A small pause to allow the motors to stop
analogWrite (E1,leftspeed); //back?
digitalWrite(M1,LOW);
analogWrite (E2,rightspeed);
digitalWrite(M2,LOW);
delay(1000);
digitalWrite(E1,LOW);
digitalWrite(E2,LOW);
delay(1000); // A small pause to allow the motors to stop
// and so on…
}[/code]goes forward, stop, goes left, stop, goes right, stop, and then goes forward not backward.
shouldn’t setting both M1 and M2 to “LOW” cause them to run backward?
UncleMike