Arduino School Project: Picnic Cooler Alarm

I am trying to make a project for school. The project will monitor the temperature of the cooler when it is open. It will have an led that will light up if the cooler is open for the user to see clearly. It will also have a buzzer that will start to beep after 1 minute so the user will know that he left the cooler open. The project will have an IR light sensor that will know if the cooler is left open. I am having a little problem with the code. This is what I have so far. The project is partially working but when I add a delay between the led and the buzzer the circuit starts acting up.

int buzzer = 11; //to notify the user
int led = 6; //will light up when the cooler is left open.
int sensor = 9; // ir module
int mode;




void setup ()
{

  Serial.begin(9600);


  mode = 0;


  pinMode(sensor, INPUT);
  pinMode(led, OUTPUT);
  pinMode(buzzer, OUTPUT);

  digitalWrite(buzzer, HIGH);
  delay(200);
  digitalWrite(buzzer, LOW);

  digitalWrite(led, LOW);
}

void sound() {
  
  digitalWrite(buzzer, HIGH);
  delay(1000);
  digitalWrite(buzzer, LOW);
  delay(1000);
}




void loop ()
{


  

  if (digitalRead(sensor) == HIGH)
  {
    digitalWrite(led, HIGH);
    delay(60000); // 1 minute delay
    mode = 1;
  }
  else if (digitalRead(sensor) == LOW)
  {
    mode = 0;
    digitalWrite(led, LOW);
  }




  switch ( mode ) {
    case 1:
      sound();
      break;

defaul: {
        // Do nothing
      }
  }



}

When I add the delay it doesn`t work properly

if (digitalRead(sensor) == HIGH)
  {
    digitalWrite(led, HIGH);
    delay(60000); // 1 minute delay
    mode = 1;
  }
  else if (digitalRead(sensor) == LOW)
  {
    mode = 0;
    digitalWrite(led, LOW);
  }

circuit starts acting up. doesn`t work properly

Those are inadequate descriptions of the problem.

Have a look at the blink without delay example (IDE examples) and the several things at a time post to see how to use millis() for your timing instead of delay(). Delay stops the processor dead in its tracks and makes your sketch unresponsive.

Hi again. Can you tell me which code you used or maybe hints. I have tried examples but I can`t understand the code.