Demonstration code for several things at the same time

Nice long example (not all examples can be 1<10 lines).

I wondered what the difference was between the attached file in the first and reply#1 with the code inline. My editor only shows comments lines are shorter :grin:

I would do it slightly different (which means neither better nor worse) :slight_smile:

I do not quite get the educational value of having update_LED_state() and switchLEDs() as seperate functions - it means you have to carry LED-desired-state as global variables, when they could be nicely encapsulated. Place most variables as static inside the function where they are exclusivly used - this way you can not inadvertently modify a timer variable elsewhere.

CodingBadly's comment is that if your loop takes - say - 5 millisec to execute (because of some not-yet-written heavy calculation code), then the LEDs will blink at the interval+5ms. By adding "interval" to the "timer" (not the measured millis() value) you get it to run at the "interval" rate. For a "real" project it may be desirable to include the loop overhead/jitter, for some you want a steady rate.