I'm a hobbyist trying to teach myself PBP by experimenting. My current project is replacing the lights in my 1973 Honda motorcycle with LEDs. When the brake light is activated, I'd like for the LEDs to pulse several times, with progressively longer intervals (100ms, 200ms, 300ms, etc) and then stay on until the brake is released. Many modern bikes do this as a deceleration warning to help avoid getting rear-ended.
In PBP, I basically run a continuous loop until a pin is high and then do a GOSUB to execute the flash loop, which takes about 2.5 seconds to complete. What I'd like to do is add some sort of timer to prevent the flash routine from executing more than once every 5-10 seconds. If I'm slowing down for a turn, I might depress and release the brake a few times. The flash loop should be executed only the first time I depressed the brake; subsequent activations should just keep the pin high until the brake is released. After x seconds, the next activation causes the flash sequence again.
From my readings, it looks like I'll need to use an interrupt to time how longer it's been since the brake was last activated. But I can't wrap my head around how to use them. Could someone please provide me with an example? Thank you!
Bookmarks