Digital LED Police Light Bar - Issue

Hi, so I am making this police light par for my rc truck. I have plans to get a couple transceivers to change the modes on the light bar. Currently I am just prototyping on my breadboard of how everything is supposed to be.

Here's my issue: I have a button that cycles through all of the modes and outputs it to serial monitor (just to have a visual). I would like a red led to flash the number of times for that mode.

Ex: Mode 5. Flash the LED 5 times. Just so when I have the remote all hooked up I can see which mode I am on.

Once I get this solved I would like to take another button to "Select" the mode. So if I press the mode cycle button 4 times. It's on the 4th mode. And to activate/run that mode press the select button to enable it....

I can supply the code that I have if needed.


So, what is the problem? Reading the state of a properly wired switch (one leg to ground, one leg to a digital pin, and the internal pullup resistor enabled for that pin) is simple. Determining that the state of the pin has changed (see the state change detection example) is simple. Incrementing a counter is trivial. Resetting the counter to 0 and doing something when the "select" switch is pressed is also trivial.