I made some arduino code for leds that blink down a row and then back again, but when the program is run, there is an approximately 2 second delay in between the first for loop and the second. This is my code in the loop function:
int leds[] = {13, 12, 11};
int i;
void setup() {
Serial.begin(9600);
for (int i = 0; i < sizeof(leds); i ++) {
pinMode(leds[i], OUTPUT);
}
}
void loop() {
for (i = 0; i < sizeof(leds); i ++) {
digitalWrite(leds[i], HIGH);
delay(250);
digitalWrite(leds[i], LOW);
}
for (i; i > 0; i --) {
digitalWrite(leds[i], HIGH);
delay(250);
digitalWrite(leds[i], LOW);
}
}
It really makes the program look weird when the LEDs are blinking on a breadboard. Keep in mind that this only happens after the first for loop, the second is continuous back to the first. Any idea why this might be and how to fix it?