Using settimeout or timer?

Ok i give up. I need help, ive been working on a small project for my nephew, ive gotten most of it out of the way, but i have a small issue with timer

Here is the logic.

Read the status of a pin (digital read)
While pin is high {
readpin again // it keeps reading the pin while in the loop. so it detects when the change occurs
start rfid
if serial found
{ check card}
if {card ok. do something.}
else{println wrong key}
else {println "No key in range" // here is my problem..I want to implement a timer that would give 20 secs to wait for the serial to come in range, if it doesnt, take the pin to low.. I cant use delay because it would just stop the program from running and i need it to keep listening, any help or ideas would be greatly appreciated

any help or ideas would be greatly appreciated

I have an idea. I think you should post your real code. All of it.

I think that, in the end, you are going to have to completely restructure your code. You are dependent on things happening in an exact order, which is not the way things really happen.