#define DELAY 400
byte leds[] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
int direction = 1;
int currentLed = 0;
unsigned long changeTime;
void setup() {
// put your setup code here, to run once:
for (int i; i < 10; i++) {
pinMode(leds[i], OUTPUT);
}
changeTime = millis();
}
void loop() {
// put your main code here, to run repeatedly:
if (millis() - changeTime > DELAY) {
changeLED();
changeTime = millis();
}
}
void changeLED(){
for (int i; i<10; i++){
digitalWrite(leds[i], LOW);
}
digitalWrite(leds[currentLed], HIGH);
currentLed += direction;
if (currentLed == 0) {direction = 1;}
if (currentLed == 9) {direction = -1;}
}