help error exit status 1 'State1' was not declared in this scope

trying to use 2 buttons and a buzzer have this error

exit status 1
'State1' was not declared in this scope

void setup() {
 const int buzzer = 2;
 const int button1 =3;
 const int button2 = 4;
  int State1;
  int State2;
  pinMode(buzzer, OUTPUT);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  Serial.begin(9600);
}

void loop() {

  State1 = digitalRead(button1);
  State2 = digitalRead(button2);
  
  if(State1 == HIGH){
    Serial.print("ok");

    
    
    
    
    
  }
if(State2 == HIGH){
    Serial.print("high")
    digitalWrite(buzzer, HIGH)
    
    
     
  }
}
  
}

Hi,
Declare your variable BEFORE the setup(), not in it.

Tom.. :slight_smile:

Or declare it when you read the state of the input in loop()