Need some help figuring out my code

Meanwhile, back at the code you posted

void switchLeds() {

      digitalWrite(rLed1, rLedState);  // and all red LEDs <- rLedState
...
      digitalWrite(wLed1, wLedState); // and all white LEDs <- wLedState
...
      digitalWrite(rLed1, aLedState); // and all red and white LEDs <- aLedState
...
      digitalWrite(wLed1, aLedState);
...
}

*aLedState* is never changed from its initial value; the function *updateaLedState*() is not used by your program.

Since aLedState has the last word in the switchLeds() function, so to speak, the LEDs will, depending on how you've wired them, always be on or off. All of them.

Technically the LEDs will briefly be switched according to rLedState and wLedState until overridden by aLedState. Briefly. Like too very fast to see by eye.

You have specified a relatively simple desired pattern:

turn white leds on for 2s then red for 2 then white for 2 then red for 2 then all for 2 repeat,

So what is this "all LEDs" code for, and why do the red and white LEDs each need two functions and two calls from loop()?

The red/white switching and timing can and should be expressed in one function that gets called over and over very frequently, usually doing nothing but when it is time, turn off the red and turn on the white or vice versa.

It is basically BWOD - blinking an LED without delay, only instead of blinking (alternate between ON and OFF) you are turning on the red (and off the white) or off the red (and on the white) LEDs.

Code writes itself. I think you can figure this out.

a7