LED CONTROL USING HC-SR04

Hi guys, please help me out with my codes. I'm trying to trigger the LED attain its maximum brightness.
What I want to do is the initial brightness of the LED should be link3(5) and when the ultrasonic sensor senses a moving object moving closer, the LED should be on link1(9). the codes below in bold letters is my problem, the one having the if and else statement. thank you

int LED=13;
#define trigger A4
#define echo A5
float time=0,distance=0;

void link1(unsigned int Pulse)

{
static unsigned int k;
for(k=0;k<100;k++)
{
digitalWrite(LED,LOW);
delay(Pulse);
digitalWrite(LED,HIGH);
delay(10-Pulse);
}
}

void link2(unsigned int Pulse1)

{
static unsigned int l;
for(l=0;l<500;l++)
{

digitalWrite(LED,HIGH);
delay(Pulse1);
digitalWrite(LED,HIGH);
delay(10-Pulse1);
}
}

void link3(unsigned int Pulse2)

{
static unsigned int m;
for(m=0;m<1000;m++)
{
digitalWrite(LED,LOW);
delay(Pulse2);
digitalWrite(LED,HIGH);
delay(10-Pulse2);
}
}

void setup()
{ Serial.begin(9600);
pinMode(trigger, OUTPUT);
pinMode(echo, INPUT);
pinMode(LED,OUTPUT);
digitalWrite(LED,LOW);
}

void loop()
{
digitalWrite(trigger,LOW);
delayMicroseconds(2);
digitalWrite(trigger,HIGH);
delayMicroseconds(10);
digitalWrite(trigger,LOW);
delayMicroseconds(2);
time=pulseIn(echo,HIGH);
distance=(time*340/20000);

link1(1);
link1(2);
link1(3);
link1(4);
link1(5);
link1(6);
link1(7);
link1(8);
link1(9);
link3(5);

** if (distance<=8){**
** link1(9);**
** }**
** else{**
** link3(5);**
** }**

link2(10);
}

I am intrigued. What thought process made you think that your question has something to do with the way the Arduino Website or Forum works?

I have suggested to the Moderator to move your Thread to the Project Guidance section.

And please modify your post and use the code button </>

so your code looks like this

and is easy to copy to a text editor. See How to use the Forum

...R

  time=pulseIn(echo,HIGH);

The pulseIn() function returns a long, NOT a float. Why are you storing the value in a float?

To make the math work when time is a long, as it should be:
distance=(time*340/20000.0);