Why have you the same code three times in this piece
void moveBackwards() {
if (state == 'B' && Fobstacle == 'N' ){
delayMicroseconds(100);
digitalWrite(LeftMotor, LOW);
digitalWrite(LeftBrake, LOW);
digitalWrite(RightBrake, LOW);
digitalWrite(RightMotor, HIGH);
analogWrite(LeftGo, 255); //Spins the motor on Channel A at full speed
analogWrite(RightGo, 255); //Spins the motor on Channel B at full speed
}
if (state == 'B' && Fobstacle == 'C' ){
delayMicroseconds(100);
digitalWrite(LeftMotor, LOW);
digitalWrite(LeftBrake, LOW);
digitalWrite(RightBrake, LOW);
digitalWrite(RightMotor, HIGH);
analogWrite(LeftGo, 255); //Spins the motor on Channel A at full speed
analogWrite(RightGo, 255); //Spins the motor on Channel B at full speed
}
else if (Fobstacle == 'A'){
delayMicroseconds(100);
digitalWrite(LeftMotor, LOW);
digitalWrite(LeftBrake, LOW);
digitalWrite(RightBrake, LOW);
digitalWrite(RightMotor, HIGH);
analogWrite(LeftGo, 255); //Spins the motor on Channel A at full speed
analogWrite(RightGo, 255); //Spins the motor on Channel B at full speed
}
}
I think this is logically identical
void moveBackwards() {
if (Fobstacle == 'A' or state == 'B') {
delayMicroseconds(100);
digitalWrite(LeftMotor, LOW);
digitalWrite(LeftBrake, LOW);
digitalWrite(RightBrake, LOW);
digitalWrite(RightMotor, HIGH);
analogWrite(LeftGo, 255); //Spins the motor on Channel A at full speed
analogWrite(RightGo, 255); //Spins the motor on Channel B at full speed
}
}
I don't know if that will solve the problem - but it should simplify the search for it ![]()
Why is the RightMotor being treated differently from the LeftMotor?
You don't have any Serial.print() statements in the code so you can monitor how any of the variables are changing.
...R