// https://wokwi.com/projects/398309878002672641
// https://forum.arduino.cc/t/strategy-for-flashing-leds/1260933
// preliminary test for status LED object
const byte leds[] = {2, 3, 4, 5,};
const byte type[] = {0b100, 0b1000, 0b11000, 0b111000,};
const byte nLEDs = sizeof leds / sizeof *leds;
void setup() {
Serial.begin(115200);
Serial.println("\nbit flash world!");
for (int ii = 0; ii < nLEDs; ii++) pinMode(leds[ii], OUTPUT);
}
# define RATE 64
void loop() {
static unsigned long lastTime;
unsigned long now = millis();
if (now - lastTime < RATE) return;
lastTime = now;
static byte flashCounter;
flashCounter++;
for (int ii = 0; ii < nLEDs; ii++) {
bool thisLED = (flashCounter & type[ii]) == type[ii];
digitalWrite(leds[ii], thisLED ? HIGH : LOW);
}
}
/* WTF
Serial.print(flashCounter, 2);
Serial.print(" ");
Serial.print(type[ii] & flashCounter);
Serial.print(" ");
Serial.println(" ");
*/