1

I was wondering, by the time I press the following key, it does not return to the main_screen() function. How can I fix my code?

void loop()
 { 
 int exit = 0;
 char input = customKeypad.getKey();
 
 main_screen();
 if (input=='A')
 { 
 delay(100);
 lcd.clear();
 
 do{
 
 lcd.setCursor(1,0);
 lcd.print("Enter minutes: ");
 
 
 if (input=='B')
 {
 break;
 lcd.clear();
 }
 }
 while(1);
 }

}

asked Jun 12, 2021 at 8:26
1
  • can you also share the complete code? Commented Jun 13, 2021 at 7:36

1 Answer 1

2

You need to read the input again after you get input == 'A'. At the moment, when you enter the do ... while loop, the input is always 'A', so input == 'B' is never true, and the loop never exits.

answered Jun 12, 2021 at 9:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.