I am trying to write a sketch that will take serial inputs to illuminate LEDs and a hardware switch to block the serial inputs while the switch is closed/HIGH. I seem to have the first part working well. I can increase and decrease the number of LEDs illuminated with Serial commands. The second part is giving me fits. I have tried "while" statements and "if" statements to examine the condition of the "toggle". It works in that it stops any additional serial commands from illuminating LEDs but when the "toggle" is switched back to "LOW" the LEDs light up with any Serial commands that I tried while the "toggle" was HIGH. As if my serial commands were stored, just waiting for the digital inputs from the toggle to go LOW and then queuing out to the LEDs one at a time.
I thought if I could stop the void loop it would stop the Serial.read and that would prevent any additional serial commands from coming through to the arduinoUNO.
Help
Oh yeah
If you hadn't figured it out already
I am new
see attached sketch
5_led_serial_control.ino (2.22 KB)