Hi, I have an arduino controlling a lamp with an IR sensor and relay switching the lamp on when motion is detected. Right now the IR sensor detects motion and counts down from 2 minutes regardless if more motion is detected or not and switches off after that. I want to modify the code so that the 2 minute countdown restarts every time motion is detected even if it is in the middle of it's 2 minute duration, and not just have a two minute timer that switches the light off after the 2 minute duration ends. Here is the code - int irmotionPin = 4; //Pin of IR Motion Sensorint relayPin = 8; // Pin of Rela - Pastebin.com
The original code comes from this tutorial- https://www.brainy-bits.com/how-to-connect-and-use-a-relay-module/
Here is the video for anyone interested - Connect a Relay and PIR Motion Sensor to an Arduino - Tutorial - YouTube
All credit goes to them, it was a really fun project and I highly recommend it!