HC-SR501 PIR Sensor and LED Blink

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.

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.

That code is mostly rubbish. A PIR does not calibrate with any sort of unknown environment around it.

That code, if we are talking about the same thing, which is hard to say for sure since you did NOT post YOUR code, simply wastes 30 seconds.

Then during the void loop

Known by intelligent people as "the loop() function"...

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.

So, do that. Do NOT use delay(), though, or you could miss the change to LOW.

Not sure if this is a hardware limitation that I can overcome with some code.

If what is? Detecting that the PIR state changed is trivial. The PIR is no different from any other switch that the state change detection example shows how to use.

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).

You say that like they are mutually exclusive. They are not. You CAN create a function. You should have some kind of control structure in the function.

Or maybe get an analog value for the PIR sensor

What is the analog value of off? Of on? How do those analog values differ from the digital values?