Here's the source to a simple but useful controller for garage lights. It's been running for 4 years: it's been tested!
An IR beam is used to detect movement. A break less than a second will not turn on the lights.
toggle lights on/off pin 17
light beam interrupt pin 18
I'm alive flashing LED. pin 6
Speaker sounder pin 7
Light relay driver pin 8
Diagnostic beam state LED pin 9
Traffic light RED (Beam not broken: car cleared door - stop now before you hit the wall!) pin 10
Traffic light GREEN (Beam broken: car not cleared door - keep moving...) pin 11