Arduino code question

Hi I am dau lum. I am doing the arduino project with ultrasonic sensor to twist the servo motor. and after twisting the servo motor, i want led to blink 5 second and stop the led unless the process will not start agin. but I am facing the problem with the led never stop. how do i write the code. now i got this code. After twisting servo i want led to on 5s and stop. How to write. can somebody help me…? Thank YOU!

#define trigPin 12
#define echoPin 13
#include <Servo.h>

Servo myservo;
int led = 4;
int duration, distance,pos=0,i;

void setup()
{
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
myservo.attach(9);

}

void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
Serial.print(distance);
Serial.println(" cm");
if(distance < 5)
{
digitalWrite(led, LOW);
myservo.write(0);
delay(4000);
}
else
{
digitalWrite(led, HIGH);
delay(2000);
myservo.write(180);
delay(3000);
}
}

Create a variable int x
Then set x to 0 in setup()
Then make the change to:

if(distance < 5 && x==0)
{
x = 1;

Etc.

Here the value x prevents the if() from evaluating a second time.

Create a variable int x

Or, use half the space, and a type that makes more sense.

bool beenThereDoneThat = false;

if(!beenThereDoneThat)
{
    GoThereDoThat();
    beenThereDoneThat = true;
}