Leave a Light On

Hi everyone! I was wondering if there was a way to add a delay to my program. This is the specific way that I want to use it:

I have made a simple app that turns on a light when motion is detected. I want to add the following features.

  1. Have the user specify a start and end time for this program to work.
    EX: You wouldn’t want lights to turn on at 12:00 p.m., since it’s daylight, so you might say 6 pm -11 pm. The dark hours until you fall asleep.
  2. Leave the lights on for x minutes even after motion has stopped
    EX: If I’m reading on my couch, I want move very much. Instead of having the lights then turn off, I would like them to stay on for 15 minutes after motion stops, so that I don’t have to be constantly moving as I read.

Thanks in advance for anyone that helps :smiley: