#include <Arduino.h>

// Five LEDs on D8-D12; edit array when changing pin layout.
// An array stores our chosen pin numbers in order. The numbers no longer need to be
// consecutive.
const int ledPins[] = {8, 9, 10, 11, 12};
// sizeof gives byte sizes; dividing total bytes by one element’s bytes gives the number of
// pins.
const int ledCount = sizeof(ledPins) / sizeof(ledPins[0]);

void setup() {
  // i is an array index: ledPins[0] is D8, ledPins[1] is D9, and so on.
  for (int i = 0; i < ledCount; i++) pinMode(ledPins[i], OUTPUT);
}

void loop() {
  // This loop visits every array position exactly once per sweep.
  for (int i = 0; i < ledCount; i++) {
    // Use the pin number stored at the current array index.
    digitalWrite(ledPins[i], HIGH);
    delay(300);
    digitalWrite(ledPins[i], LOW);
  }
}
