pin mode changing makes arduino stutter

Im making a simple car with a IR sensor on when the IR sees something in front of it,it turns right. easy right. but when the if statement in the loop is no longer true the car stops the right weal twitches the "L" LED flashes a few times then only it turns right... what gives :confused: thanks for the help in advance

int IRFront;
void setup() {
  // put your setup code here, to run once:
  pinMode(3, INPUT);


void loop() {
  // put your main code here, to run repeatedly:
  IRFront = digitalRead(3);
  if (IRFront == 0){
    digitalWrite(11, LOW);
    digitalWrite(12, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
  else if (IRFront == 1){
    digitalWrite(11, HIGH);
    digitalWrite(12, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(8, LOW);
  1. Which arduino do you have?
  2. What is connected to each of the pins? You can give names to the pins for clarity/sanity of the reader
const uint8_t leftMotorPin = 11;
// ...
digitalWrite(leftMotorPin, HIGH);
  1. What IR sensor are you using?
  2. You are missing two closing brackets at the end of the code (copy and paste error?)

That is not the whole sketch.

We have no idea what hardware you have nor how it is all connected or powered (I could guess, but won't waste my time doing so).

I don't see anywhere in your code where you change the mode of any pins, so you didn't even get the thread title right.