Sorry if this seems to be a noob question, but it's been a long time since I've done anything with Arduino and I'm steadily relearning everything.
I recently wrote a simple LED cycle code (attached) to cycle through 5 leds one at a time. I've been using and USB battery to power the board. For some reason, the assembly works for a couple minutes and then randomly stops. Unplugging and replugging it resets it. I don't know if it's my for loop getting hung up, some sort of clock problem, or if there's some sort of idle setting. Any suggestions?
// That code thing that Kith wrote
//Variables
int leds[] = {2,3,4,5,6}; // Array of the pins used
int d=100; // Delay time in millisecondsvoid setup()
{
for(int i=0; i<5; i++){
pinMode(leds*,OUTPUT);*
- }*
}
void loop()
{- for(int i=0; i<=7; i++){*
_ digitalWrite(leds*, HIGH);_
_ if(i!=0){_
_ digitalWrite(leds[(i-1)], LOW);_
_ }_
_ delay(d);_
_ }_
_ for(int i=7; i>=0; i--){_
_ digitalWrite(leds, HIGH);
if(i!=7){
digitalWrite(leds[(i+1)], LOW);
}
delay(d);
}
}
[/quote]*_