So I have a situation that I'm sure many of you have... I have kids that like to leave lights on all around the house. What I would like to do is start a timer based on the motion sensor tied to my ELK security system in the kids playroom. So when the turn the lights on, it will start a timer for say 5 minutes and if there is motion detected, it will extend that another 5 minutes. I'm trying to wrap my head around the best way to do this. I have state variables setup and a program that updates the motion state variable to 1 if it detects motion and 0 when the motion stops. However, I'm not sure of the best way to implement the timer. I'm stuck on how to best implement the rest.
Any thoughts would be greatly appreciated!