Updating a sensor until an "action" occurs

Hi all,

I am a beginner here and this is my first project and topic. I am working on Arduino Uno and my system consists of: 3 buttons, 3 LEDs, 1 LCD, 1 piezo and 1 thermosensor. My goal is to create a digital locker with 3 digits, leds and sounds but I would also like to insert a thermosensor that can detect the room temperature updating it every tot. seconds until it is interrupted by any button. At the moment, everything works fine, but the sensor does not update if I do not press a button.

Could help me with my code? I am sharing it below.
Thank you in advance.

Best,

#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,1);

const int button[] = {13,8,7};
const int ledpin[] = {10,9,6};

int ButtonState[] = {0,0,0};
int lastButtonState[] = {0,0,0};
int password[] = {0,2,1,0};
int level = 0;


const int Sensor = A0;
bool onAndOff = false;

void setup() {
  //Serial.begin(9600);
  //Serial.println("Select a button");
  
  
  
  pinMode(Sensor, INPUT);
  pinMode(button[0], INPUT);
  pinMode(button[1], INPUT);
  pinMode(button[2], INPUT);
  
  pinMode(ledpin[0], OUTPUT);
  pinMode(ledpin[1], OUTPUT);
  pinMode(ledpin[2], OUTPUT);
  
  lcd.begin(16,2);
  lcd.setCursor(0, 0);;
  lcd.print("Welcome");
  lcd.setCursor(0, 1);
  lcd.print("Buddy");
  delay(4000);
  lcd.clear();


}

void loop() {

if(onAndOff == false){
  champagne();
  
  loop();
}
        
  
  for(int i=0; i<4; i++){   
    ButtonState[i] = digitalRead(button[i]);
    
    if(ButtonState[i] != lastButtonState[i]){

      if(ButtonState[i] == LOW){
        
        switch(level){
          case 0: {if(i == password[0]){
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("Set the code:");
            
            
            //Serial.println("Set the code");
            digitalWrite(ledpin[1], HIGH);
            delay(1000);
            digitalWrite(ledpin[1], LOW);
            
            level++;       
          }
            else {
              //Serial.println("Button 1");
              lcd.clear();
              digitalWrite(ledpin[0], HIGH);
              
      
              lcd.setCursor(0, 0);
              lcd.print("Press the button");
              lcd.setCursor(0, 1);
              lcd.print("1 to set the Psw");
              delay(1000);
              digitalWrite(ledpin[0], LOW);
              
              level=5;
            }}
                  break;
          case 1: {if(i == password[1]){
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("Set the code:");
            lcd.setCursor(4, 1);
            lcd.print("*");
            delay(500);
            
            level++;
          }
                  else {
              
                //    Serial.println("Button 1");
              lcd.clear();
              digitalWrite(ledpin[0], HIGH);
              
      
              lcd.setCursor(0, 0);
              lcd.print("Press the button");
              lcd.setCursor(0, 1);
              lcd.print("1 to set the Psw");
              delay(1000);
              digitalWrite(ledpin[0], LOW);
                    level=5;
                  }}
                  break;
          case 2: {if(i == password[2]){
            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("Set the code:");
            lcd.setCursor(4, 1);
            lcd.print("**");
            delay(500);
            
            level++;
          }
                  else {
              
                  //  Serial.println("Button 1");
              lcd.clear();
              digitalWrite(ledpin[0], HIGH);
              
      
              lcd.setCursor(0, 0);
              lcd.print("Press the button");
              lcd.setCursor(0, 1);
              lcd.print("1 to set the Psw");
              delay(1000);
              digitalWrite(ledpin[0], LOW);
                    level=5;
                  }}
                  break;
          case 3: {if(i == password[3]){

            lcd.clear();
            lcd.setCursor(0, 0);
            lcd.print("Set the code:");
            lcd.setCursor(4, 1);
            lcd.print("***");
            delay(1000);
            lcd.clear();
            
            level++;
          }
                  else {
              
                    //Serial.println("Button 1");
              lcd.clear();
              digitalWrite(ledpin[0], HIGH);
              
      
              lcd.setCursor(0, 0);
              lcd.print("Press the button");
              lcd.setCursor(0, 1);
              lcd.print("1 to set the Psw");
              delay(1000);
              digitalWrite(ledpin[0], LOW);
                    level=5;
                  }}
                  break;
          }
      }
      lastButtonState[i] = ButtonState[i];
    }
  }

  
  
  if(level==4){
    
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Psw is correct!");
    digitalWrite(ledpin[2], HIGH);
    delay(1000);
    digitalWrite(ledpin[2], LOW);
    delay(100);
    
  
  digitalWrite(ledpin[0], HIGH);
  digitalWrite(ledpin[1], HIGH);
  digitalWrite(ledpin[2], HIGH);
  tone(2, NOTE_D4);
  delay(200);

  digitalWrite(ledpin[0], LOW); 
  digitalWrite(ledpin[1], LOW);
  digitalWrite(ledpin[2], LOW);
  noTone(2);
  delay(200); 
  
  digitalWrite(ledpin[0], HIGH);  
  digitalWrite(ledpin[1], HIGH);
  digitalWrite(ledpin[2], HIGH);
  tone(2, NOTE_D4);
  delay(1000);
  noTone(2);
  lcd.clear();
  digitalWrite(ledpin[0], LOW);  
  digitalWrite(ledpin[1], LOW);
  digitalWrite(ledpin[2], LOW);
  champagne();
    level=0;
    }

  if(level==5){
    for(int j=0; j<4; j++){
      
      
      lcd.clear();
    }
    champagne();
    level=0;
    
  }

  
 
  delay(20);

}



void champagne(){
  float temp_reading = analogRead(Sensor);
  float temperaturec = temp_reading*(5.0/1023.0)*100;
  float temperature = (temperaturec-32)/1.8;
  delay(10); 

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Temp in C:");
  lcd.setCursor(11,0);
  lcd.print(temperature);
  lcd.setCursor(0,1);
  lcd.print("Press to update");
  //lcd.print(" C");

  onAndOff = true;
  
 

}

Don't ever call loop.

void loop() {

  if (onAndOff == false) {
    champagne();

    loop();
  }
//...

This is recursion

You also set onAndOff equal to true inside champagne() so that if() statement won't ever be called again. You do call champagne() in a couple of different levels, but not all.