SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By brianuno
#194167
I need help modifying a sketch for my own purposes. I am trying to blink a LED which is now a steady glow. This is the tutorial I am using for a guide: https://learn.sparkfun.com/tutorials/pi ... okup-guide, including the stock sensor. Up to now, by copying blink code from various sketches, I managed to make the LED blink. The problem is it doesn't stop blinking! That gave me an idea for an alarm application. Let's say a PIR sensor is used for a secure door that is normally not watched. Any disturbance rings an alarm until the cause is investigated and the alarm shut off. But since I can't figure out how to stop the blink after a certain length of time my code is probably not standard. I am hoping to get the idea of blinking output, not just fix this sketch, so that I can apply it to future projects. I noticed that the response to questions about code problems is often, "What exactly do you want to do?" What I want to do is blink a LED when input is received from a PIR sensor. I want it to alternate one second on, one second off, for 10 seconds, or 5 x .5 second blinks, alternating with .5 second pauses. I am not sure which is the better definition. If the sensor response is an anomaly, the blink terminates after the specified time or count. If the sensor continues to detect motion, the blink continues, until the sensed motion finally stops. Line numbers are turned on in my IDE window for where code changes are needed.