I have made this small program to lighten up in sequence 8 LEDs, it starts fine, but it stops working after a minute or so and the first 2 LEDs stay permanently ON, its like the chip stoped, here is the code :
// Initialize an array with all 8 leds
// and give them the corresponding
// digital number.
const byte led[8] = {0,1,2,3,4,5,6,7};
// the setup routine runs once when you press reset:
void setup() {
// initialize all 8 digital I/O pins as outputs.
for (byte i = 0; i<9; i++) {
pinMode(led[i], OUTPUT);
}
pinMode(13, OUTPUT);
}
void left (void);
void right (void);
// the loop routine runs over and over again forever:
void loop() {
right();
left();
}
void left (void) {
for (byte i = 0; i<9; i++) {
digitalWrite(led[i], HIGH);
delay(50);
digitalWrite(led[i], LOW);
}
}
void right (void) {
for (byte i = 8; i>0; i--) {
digitalWrite(led[i], HIGH);
delay(50);
digitalWrite(led[i], LOW);
}
}
I am using a very old arduino duemilanove.