Motor and proximity sensors - continue for 1 second after sensor is tripped

PaulS:
You need a variable to keep track of the state of the gate - open, opening, closed, closing, etc. When the gate is closing, and the proximity sensor becomes low, run the motor for one second longer, then shut it off and set the state to closed.

Hmm yeah so are you suggesting switch/case statements or boolean?