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);
       }

}

1
  • can you also share the complete code?
    – ArduinoFan
    Jun 13 at 7:36
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.