I built a simple project to control the lights in my kids bedroom using an HC-SR501 PIR Sensor, RF transmitter/receiver combo, and a relay.
All works well but I am trying to improve the functionality of the LED. I am using the common code found throughout this as well as other sites whereby during void setup the PIR sensor calibrates for 30 seconds with an LED flash each second to signify that the PIR sensor is calibrating. Then during the void loop if the value of the PIR sensor goes to HIGH, the LED turns on and stays on until the value of the PIR sensor goes to LOW.
I would like the LED to flash a couple of times when the PIR goes to HIGH and then flash once when it goes to LOW. I have the delay potentiometer set to about 30 seconds and the trigger jumper set to retrigger. It would be nice if everytime the retrigger is tripped, the LED would flash again a couple of times to denote that motion has again been detected.
Not sure if this is a hardware limitation that I can overcome with some code. Just looking for someone to point me in the right direction. I have basic C++ understanding and have reference material. I was thinking that I could create a function to control the LED that would get called during the loop. Or maybe using some control statement (if, for, while, do, switch, break, continue). Or maybe get an analog value for the PIR sensor if one is available that reads voltage before retrigger and after retrigger.
Thanks for the help.