Arduino whiskers arent working well

Hi guys,
my Arduino robot/car is not functioning as I wanted it to. I want it to go straight forward and turn to the appropriate direction when the specific whisker is touched to avoid hitting the wall.
this is my code if it will make a difference:

#include <Servo.h>

Servo servoLeft;
Servo servoRight;

void setup()
{
pinMode(7, INPUT);
pinMode(5, INPUT);

tone(4, 3000, 1000);
delay(1000);

servoLeft.attach(13);
servoRight.attach(12);
}

void loop()
{
byte wLeft = digitalRead(5);
byte wRight = digitalRead(7);

if((wLeft == 0) && (wRight == 0))
{
backward(1000);
turnLeft(800);
}
else if(wLeft == 0)
{
backward(1000);
turnRight(400);
}
else if(wRight == 0)
{
backward(1000);
turnLeft(400);

else
{
forward(20);
}
}

void forward(int time)
{
servoLeft.writeMicroseconds(1700);
servoRight.writeMicroseconds(1300);
delay(time);
}

void turnLeft(int time)
{
servoLeft.writeMicroseconds(1300);
servoRight.writeMicroseconds(1300);
delay(time);
}

void turnRight(int time)
{
servoLeft.writeMicroseconds(1700);
servoRight.writeMicroseconds(1700);
delay(time);
}

void backward(int time)
{
servoLeft.writeMicroseconds(1300);
servoRight.writeMicroseconds(1700);
delay(time);
}

Do you have external pulldown resistors wired with the whiskers?

The code you posted incorrectly does something. You did not say what it does.

You want it to do something. The only thing I can guess is that what you want it to do is not what it actually does.

Please read the two posts at the top of the Forum by Nick gammon on the proper way to post code here. It makes it easier for us to read.

Faisal_Darwish: Hi guys, my Arduino robot/car is not functioning as I wanted it to. I want it to go straight forward and turn to the appropriate direction when the specific whisker is touched to avoid hitting the wall. this is my code if it will make a difference:

Your code won't compile:

  else if (wRight == 0)
  {
    backward(1000);
    turnLeft(400);

    else
    {
      forward(20);
    }
  }
sketch_nov14a:38: error: expected '}' before 'else'
     else
     ^

Change it to:

  else if (wRight == 0)
  {
    backward(1000);
    turnLeft(400);
  }
  else
  {
    forward(20);
  }
}