For loop and array to sequence outputs on but go random after one iteration

I am having trouble understanding this; I don’t know why the LED outputs seemly go random after one iteration of the for loop. ← a short recording of what the LED outputs are doing.

int LEDarray[] = {2,3,4,5,6,7,8,9};
int x =0;
int timer = 5;
void setup() {

for (byte i=0; i<9; i++){
  pinMode(LEDarray[i], OUTPUT);

void loop() {
for (byte y=0; y<9; y++){
x = 0; 
while (x<255){
 analogWrite(LEDarray[y], 0);

what am I missing?

Instead of “<9”, use “<8”.

Entries in arrays start numbering at 0; you have 8 entries the valid indexes into the array are 0…7. Any higher and you’re outside the array referencing who-knows-what.

Thank you. :confused: