Hi, my arduino car does not turn left and right appropraitely. It rotates non-stop. Do you have have any ideas how can I make my car turn appropraitely? I'm trying LM393 to count the steps and make sure that it stops when the steps counted is 55. Here is my code:
stepsRight=0;
while(digitalRead(sensorRight)) {
stepsRight=stepsRight+1;
Serial.println(stepsRight);
while(stepsRight<55) {
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, LOW);
}
if(stepsRight=55) {
digitalWrite(motor1Pin1, LOW);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin1, LOW);
digitalWrite(motor2Pin2, LOW);
break;
}
}