Q:

arduino car with ultra sonic sensors

I have a problem with my code. I wired everything correctly, but the values that the sensors read are either wrong. Or the code I wrote is wrong. The car never stops when something is within 20cm of the front sensor. It rather just keeps driving. The RC car is hooked up to the arduino with 3 ultrasonic sensors. And the RC motors are driven by an H-bridge(not the shield). The commented code parts are the code for if the RC car had a servo. But this car had 2 RC motors.
Here is the code:
 //Libraries.
//#include <Servo.h>
#include <NewPing.h>

//Variables.
/*const int pos = 103; //Servo midden 103*
  const int StrLeft = 70; //Serv0 naar links.
  const int StrRight = 133; //Servo naar rechts.*/
int Left = 5;
int Right = 4;
int Forwards = 3;
int Backwards = 2;
int potPin = A0;
int speed = 0;
#define TRIGGER_PIN1 11 //Front 
#define ECHO_PIN1 12
#define TRIGGER_PIN2 7 //Left
#define ECHO_PIN2 8
#define TRIGGER_PIN3  9 //Right
#define ECHO_PIN3 10
#define MAX_DISTANCE 200
#define MAX_DISTANCEF 1000

//Name of the objects.
//Servo MyServo;
NewPing sonar1(TRIGGER_PIN1, ECHO_PIN1, MAX_DISTANCEF);//Front
NewPing sonar2(TRIGGER_PIN2, ECHO_PIN2, MAX_DISTANCE);//Left
NewPing sonar3(TRIGGER_PIN3, ECHO_PIN3, MAX_DISTANCE);//Right

//Start of the program.
void setup() {
  Serial.begin(9600);
  int Fwd = false;
  /*MyServo.attach(9); //Pin number of the attached Servo.
    MyServo.write(pos); //Resets to this posistion automatically.*/
  pinMode(Left, OUTPUT);
  pinMode(Right, OUTPUT);
  pinMode(Forwards, OUTPUT);
  pinMode(Backwards, OUTPUT);
}

//During the program.
void loop() {
  //Sturen
  /*MyServo.write(pos);
    delay(1000);
    MyServo.write(StrLeft);
    Serial.print("Links");
    delay(1000);
    MyServo.write(StrRight);
    Serial.print("Rechts");
    delay(1000);
    MyServo.write(pos);
    delay(1000);*/
  //Value of the potentiometer
  speed = analogRead(potPin);
  speed = map(speed, 0, 1023, 0, 179);
  Serial.print(speed);

  //Sensor
  unsigned int distanceF = sonar1.ping_cm();//Front
  unsigned int distanceL = sonar2.ping_cm();//Left
  unsigned int distanceR = sonar2.ping_cm();//Right
  Serial.print(distanceF);
  Serial.print(distanceL);
  Serial.print(distanceR);
  Serial.print("cm");
  delay(50);

  //Values for driving
  if (distanceF > 50 ) {
    int Fwd = true;
    Serial.print("true");
  } else {
    int Fwd = false;
    Serial.print("false");
    Stp();
  }
  delay(50);
  if ((distanceF = true) && (distanceL > distanceR)) {
    fwdLeft();
  } else if ((distanceF = true) && (distanceR > distanceL)){
    fwdRight();
  }
  delay(50);
}
void fwdLeft() {
  digitalWrite(Forwards, HIGH);
  digitalWrite(Backwards, LOW);
  digitalWrite(Left, HIGH);
  digitalWrite(Right, LOW);
}
void fwdRight() {
  digitalWrite(Forwards, HIGH);
  digitalWrite(Backwards, LOW);
  digitalWrite(Left, LOW);
  digitalWrite(Right, HIGH);
}
void Stp() {
  digitalWrite(Forwards, LOW);
  digitalWrite(Backwards, LOW);
  digitalWrite(Left, LOW);
  digitalWrite(Right, LOW);
}

A:

In the comments, you said that that Fwd variable never changes.  Note that you have three different variables name Fwd, though it seems you probably intended to have one global one.
The first is in setup:
void setup() {
  Serial.begin(9600);
  int Fwd = false;
  // ...
}

This Fwd is local to setup.  It's set but never read.  Once setup is finished, it no longer exists.
The other two are here:
if (distanceF > 50 ) {
  int Fwd = true;
  Serial.print("true");
} else {
  int Fwd = false;
  Serial.print("false");
  Stp();
}

Each of those is a new variable that's local to the scope in which it's defined (from the definition until the closing curly brace).  Again, these are set but never inspected.
I think what you intended is to declare a global variable outside of any function:
int Fwd = false;

Then, whenever you want to change it, you'd just assign to it without repeating the type:
Fwd = true;

Then you have lines like this:
if ((distanceF = true) && (distanceL > distanceR))

I'm not sure what you intended by (distanceF = true), but I don't think that code does what you think it does.  Since you used a single =, that's an assignment not a comparison.  So your if-condition is actually changing the value of distanceF to true rather than checking to see if it is true (or non-zero).  I suspect you wanted Fwd there:
if (Fwd && (distanceL > distanceR))

None of that explains why the car doesn't actually stop though.  I suspect you also have a problem reading the data from the ultrasonic sensor.  Perhaps the units aren't what is expressed in the code or you need to do some averaging (or other filtering) of the readings in order to reduce noise and faulty readings.

