Increase the value by one , once the button is activated (pushbutton)

Every time I push a button, I want to increase the value by one value which is (menucourant). I want to menu select the other 3 options which are lireTemperature();-temperature, gererRetroeclairage();-Lighting and gradateurs();-bar graphs.

void lireLesBoutons(){
 
 Etat1=digitalRead(pinBouton[1]); 
 Etat2=digitalRead(pinBouton[2]);
 
 if(Etat1==HIGH){
   menuCourant++;
 Etat1=digitalRead(pinBouton[1]); 
 Etat2=digitalRead(pinBouton[2]);
 Serial.print(Etat1);
 if(menuCourant>2){
   menuCourant=0;
 }
 }

 if(Etat2==HIGH){
   menuCourant--;
 Etat1=digitalRead(pinBouton[1]); 
 Etat2=digitalRead(pinBouton[2]); 
 Serial.print(menuCourant);
 Serial.print(Etat2);
 if(menuCourant<0){
   menuCourant=0;
 }
 }
 
}

If the button is held, then it may cause issues with your counter, so look into the example sketch StateChangeDetection.

couldn't find any repositories matching 'StateChangeDetection'

Nick2012Future: couldn't find any repositories matching 'StateChangeDetection'

It is one of the examples that come with the Arduino IDE

...R

Ok I got it thank's!!