// define the pins for the LEDs
int ledPins[] = {22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53};
// set the number of LEDs
int numLeds = sizeof(ledPins) / sizeof(int);
// set the delay time between LED updates
int delayTime = 50;
// set the current LED index
int currentLed = 0;
// set the current LED direction
int direction = 1;
void setup() {
// initialize all LED pins as outputs
for (int i = 0; i < numLeds; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
// turn off the current LED
digitalWrite(ledPins[currentLed], LOW);
// increment the current LED index
currentLed += direction;
// check if we've reached the end of the LED array
if (currentLed == numLeds - 1 || currentLed == 0) {
direction = -direction;
}
// turn on the new current LED
digitalWrite(ledPins[currentLed], HIGH);
// delay before updating the LEDs again
delay(delayTime);
}