traffic light project!

Thank you very much.. and sorry for not posting the code the right way.. this post literally my first one! lol

below is the diagram I used for my circuit - the only thing is missing from it is the ultrasonic sensor and am using red and green traffic light not yellow.. and yes im using for parking the car inside my garage.. i can post a video to show how it works.. but i dont think the forums allows video format..

Thanks!

Below is a copy of code again..

#define trigPin 12
#define echoPin 13
#define ledR 4
#define ledG 5

void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(ledR, OUTPUT);
  pinMode(ledG, OUTPUT);
}

void loop() {
  long duration, distance;
  digitalWrite(trigPin, LOW); 
  delayMicroseconds(2); 
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); 
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  if (distance <= 150) {  
    digitalWrite(ledR,HIGH); // Turn the Red light on when the distance is 150cm or less 
    digitalWrite(ledG,LOW);
}
  else {
    digitalWrite(ledR,LOW); // Turn the Green light
    digitalWrite(ledG,HIGH);
  }
  if (distance >= 400 || distance <= 0){
    Serial.println("Out of range");
  }
  else {
    Serial.print(distance);
    Serial.println("cm");
  }
  delay(200);
}