Arduino Car turning left and right appropraitely

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;
        }
      }

A single equal sign '=' is the assignment operator. Two equal signs '==' is the comparison operator. You are doing an assignment in that last if() statement.

It is always better to post your complete code, not snippets.

@rosesmadison

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.

Hi,
How many wheels does your car have?
Can you along with your entire code please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile: