Building a car

Thanks for the answer. The car will use a ultrasonic distance sensor; the HC-Sr04. I was experimenting with it and have managed to make a relatively accurate distance sensor. However, i tried to make an led light up when the distance dropped below a certain amount, but it did not work. The distance measurements are still working properly, however the led instead of lighting up just has a very faint tiny glow which does not change no matter what I do.

This is my code:

const int trig = 8;
const int echo = 9;
const int led = 7;

void setup()
{
Serial.begin(9600);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
pinMode(led, OUTPUT);
digitalWrite(led, LOW);

}

void loop()
{
float duration,distance;

digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);

duration = pulseIn(echo, HIGH);

distance = (duration/2)* 0.0344;

if (distance < 15)
{
digitalWrite(led, HIGH);
}

Serial.println(distance);

}

What am I doing wrong?