Piezo, countdown sound HELP !

Hi!

Im making a board game, and I’ve made a timer i have 6 LEDs, it works like an “hourglass”. When button is pressed, all LED’s goes on and then, each 10 seconds the light will turn off, one by one… And Im stuck, i have been struggling for HOURS… I want a sound from my Piezo to make a sound “when the time is up” ( after those 60 seconds )… Also I want the button to be able to use again after it has been used… As it is now, i need to reload / reset the Arduino for it to work again… Im new with Arduino, only been programming in Processing before…

here’s my code so far:

int Piezo = 8; // pin of piezo
int button = 12;  // button to press to start countdown
int buttonState = 0;  
int Pins[]={
  0,1,2,3,4,5,6}; // array of pins (LEDs Pins) 

void setup(){
  
  pinMode(Piezo, OUTPUT);  //piezo
  pinMode(button,INPUT);

  for (int i = 0; i<6; i++){
    pinMode(Pins[i],OUTPUT);
  }
}

void loop(){
  
  buttonState = digitalRead(button);
  if (buttonState == HIGH){

    for (int count=0; count<6; count++){
      digitalWrite(Pins[count], HIGH);    //this for loop lights all LEDs
      delay (0);
    }

    for (int i = 6; i <=6; i--){
      digitalWrite(Pins[i],LOW);   // This for loop kills one LED, one by one each 10 seconds
      delay(10000);

      if (i==0){
        digitalWrite(Piezo,HIGH);
        delay(2000);                      // this piezo is suppose to make a sound after thoose 60 seconds
      }
      else{
        digitalWrite(Piezo,LOW);
      }

    }
  }
}

Please tidy up the code using the tool in the IDE and post it here using code tags (# above the smileys)
It will make it much easier to help

Why the hurry ?

UKHeliBob: Please tidy up the code using the tool in the IDE and post it here using code tags (# above the smileys) It will make it much easier to help

Why the hurry ?

No specific reason to hurry, just tired after trying and a lot of failing... Just frustrated right now, i wanna know whats wrong... I like to solve most of my things myself but this really got on my nerves.. 8)

Look at the for loop that turns the LEDs off

for (int i = 6; i <=6; i--)

Do you want it counting down from 6 or 5 - array elements are numbered from 0 upwards
Will it ever stop ? - try printing out the value of i inside the loop to see what is going on
What sort of device is attached to pin 8 ?

UKHeliBob:
Look at the for loop that turns the LEDs off

for (int i = 6; i <=6; i--)

Do you want it counting down from 6 or 5 - array elements are numbered from 0 upwards
Will it ever stop ? - try printing out the value of i inside the loop to see what is going on
What sort of device is attached to pin 8 ?

Ahh… So its the loop that is blocking the function to use the button again… Is it possible to break the loop with a command in arduino IDE? Like a break function? Its a simple arduino “starter arduino”… The LEDs är connected from 0-6… 0 rx, 1 tx,3,4,5,6…

No need to break out of the loop ! As I suggested, try printing the value of i in the loop. What prints out ? Does it stop at zero ?