Array update algorithm freezing code?

For some reason, when I run this code, all that gets printed is "Ar". I'm using the Arduino Web Editor.

int soundArray[] = {1,1,1,0,0,0};
int out = 0;

void setup() {
  
  pinMode(2,INPUT);
  Serial.begin(9600);
  
}


void loop() {

  Serial.print("Array: ");
  for(int i : soundArray){
    Serial.print(i);
    Serial.print(", ");
  }
  Serial.print("Output value: ");
  Serial.println(out);
  
  
  
    // Update array by shifting iteratively
  for(int i = 5;i > 0;i++){
    soundArray[i] = soundArray[i - 1];
  }
  soundArray[0] = digitalRead(2);


 
  delay(1000);
  
}

Oops

1 Like

:slight_smile:
Thanks, friend.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.