Simple Code For Beer Pong

Im having an issue writing a simple code for my new beer pong table. What i have so far is for an led to be lit at a state determined by a photo resistor when the cup is on top of it, then you lift the cup and it changes to another led, but it also makes a seperate led flash, what im trying to do is get the other LED to flash for around 5 seconds then stop until it is reset but im completely stumped on how to stop a section of the void loop(). any help?

int sensePin =0;
int ledPin = 9;
int ledPins = 4;
int flash = 10;

void setup(){
analogReference(DEFAULT);

pinMode(ledPin, OUTPUT);
pinMode(ledPins, OUTPUT);

}

void loop() {
int val = analogRead(sensePin);

if(val < 20) digitalWrite(ledPin, HIGH);
else digitalWrite(ledPin, LOW);

if(val < 20) digitalWrite(ledPins, LOW);
else digitalWrite(ledPins, HIGH);

if(val > 20) digitalWrite(flash, HIGH);
delay(500);
digitalWrite(flash, LOW);
delay(500);
}

im completely stumped on how to stop a section of the void loop(). any help?

yea, dont

look at blink without delay, it starts a simple clock when the system is turned on, from there its just a matter of recording timestamps and subtraction