I wrote this for my Arduino mega 2560:
int LED[14] = { 28,29,30,31,32,33,34,35,36,37,38,39,40,41 } ; ... ... (some other code like setup(), etc. Note:pinmode output for this 14 leds wich pins is defined in ... array named LED[] ... void intro(){ for(int j=1; j<100; j++ ){ for(int r=1; r<15; r++ ){ digitalWrite(LED[r],HIGH); delay(100); } delay(100); for(int r=1; r<15; r++ ){digitalWrite(LED[r],LOW); delay(100);} delay(100); } Serial.print("Pattern started"); delay(1000); }
So when i run this script, i expect that each led will light up in the sequence and remaining lighted until the second lop to turn it off but i see that when lighting each led, when lighting the 9th led, the first 8 led shut off unexplicately and the led 9 troug 14 light one by one remaining light. that I expected but why the first 8 led shut off before the lopp ends and the second loop appear ??? Excuse my bad englis