Menu with PushButtons

Hi! I have a doubt about building a menu with pushbuttons.
Initially, I have to wait for a button to be pressed.
When someone goes, I have to open the option for the button pressed. I tried as follows but I was not successful. Does anyone have any suggestions?

void loop()
{
int button1 = digitalRead(but1);
int button2 = digitalRead(but2);

while(button1 == LOW && button2 ==LOW){};
while(button1 == HIGH || button2 ==HIGH){
if(button1 == HIGH){
Serial.print("RFID")
rfid_menu();
}

if(button2 == HIGH){
Serial.print("FingerPrint")
fingerprint_menu();
}
};

}

You don't need whiles. All you need is if button1 is high do something, if button2 are high do something. Otherwise it will keep looping round checking until one of them is high.

Steve

Try this:

In below while-loops, the values of button1 and button2 never change.

while(button1 == LOW && button2 ==LOW){};
while (button1 == HIGH || button2 == HIGH)
{
  ...
  ...
}

So once you're in one of those while-loops, you will forever stay in there.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.