Add delay to "digitalWrite( ledPin,LOW);" via a pushbutton and resume code

Alvingston:
I'm building a lucid dreaming induction device, that while asleep and dreaming would deliver flashing lights to recognize the dream state.

How exactly does the Arduino know you are in REM state?