// Define the total number of LEDs
const int NUM_LEDS = 8;
// Define the pin assignments for the LEDs (assuming 8 LEDs connected to digital pins 2 to 9)
const int LED_pins[] = {2, 3, 4, 5, 6, 7, 8, 9};
void setup() {
// Initialize LED pins as output
for (int i = 0; i < NUM_LEDS; i++) {
pinMode(LED_pins[i], OUTPUT);
}
}
void loop() {
// Circular LED activation pattern: 0-1-2-3-7-6-5-4
for (int i = 0; i < NUM_LEDS; i++) {
// Calculate the index based on the circular pattern
int index = (i <= 3) ? i : (NUM_LEDS - i + 3) % NUM_LEDS;
// Turn on the LED at the calculated index
digitalWrite(LED_pins[index], HIGH);
// Turn off the previously lit LED
int prev_index = (index == 0) ? NUM_LEDS - 1 : index - 1;
digitalWrite(LED_pins[(prev_index + 1) % NUM_LEDS], LOW);
// Delay for one second
delay(1000);
}
}