hc-sr04 sensor how can i make a led high if it detects a object for 5seconds?

here is my code… im planing to add a statement that if it detects a object for a given time it will turn on a led. is it possible?

#define echoPin 7
#define trigPin 8
#define LEDPin 13
#define led 12 // given time

int maximumRange =150;
int minimumRange = 0;
long duration, distance;

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LEDPin, OUTPUT);
pinMode(led,HIGH);
}

void loop() { digitalWrite(trigPin, LOW);
delayMicroseconds(1);

digitalWrite(trigPin, HIGH);
delayMicroseconds(1);

digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);

distance = duration/58.2;

if (distance >= maximumRange || distance <= minimumRange){
Serial.println("-1");
digitalWrite(LEDPin, LOW);
}

else {
Serial.println(distance);
digitalWrite(LEDPin, HIGH);
delay(1000);

}

Yes it is possible.
Record the starting milliseconds.
Loop until either 5000 milliseconds has elapsed, or the object is no longer detected.
If after 5 seconds the object is still there, turn on the LED.

    static unsigned long startingTime = 0;

    // Whenever an object is NOT detected, record a starting time:
    if (object not detected)
        startingTime = millis();

     // If more than 5 seconds have elapsed since the last time no object was detected
     if (millis() - startingTime >= 5000UL) {
         // light up the LED
     }