My situation I'm using shift registers to control 72 LEDs individal. Each LED can be activated via a specific request. It is easy to set the LED to HIGH, but the LED should blink. Making the LED blink via "for" is not a problem. I managed to make the LED blinking, once it it blinking it does not stop when a new request comes in. The LED should blink only till a new request arrives.
My problem is if during the blinking peroid (in the example 3 times) I can not stop it. If I'm sending a new if(readString.indexOf("?button1onA2") > 0)
for example for an other LED (?button1onA2) the request will be ignored as long as the LED from the request before is still blinking.
My target is to make the LED blink, but stop when a new request via 'readstring' arrives.
My Question:
- is there a better way to make the LED flashing in a loop other then using
for (i = 0; i < 3; i++)
? - one I'm in the loop how can I break it and move on to the next LED?
My code
if (readString.indexOf("?button1onA1") > 0)
In this case the LED with the sensor ID 4 should blink.
if (readString.indexOf("?button1onA1") > 0) {
for (i = 0; i < 3; i++)
{
shifter.setPin(4, HIGH);
shifter.write();
delay(200);
shifter.setPin(4, LOW);
shifter.write();
delay(200);
}