Please help with code

Hi All, would you help with above part of code I'm guessing its incorrect brackets. Thanks

void menuItem4() { // Function executes when you select the 4th item from main menu
  int activeButton = 0;
  while (1) {
    DateTime now = rtc.now(); //Attaches now to action1 scope
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print(now.hour(),DEC);
    lcd.print(':');
    lcd.print(now.minute(),DEC);
    lcd.print(':');
    lcd.print(now.second(),DEC);
    delay(1000);
     
  }

  while (activeButton == 0) {
    int button;
    readKey = analogRead(0);
    if (readKey < 790) {
      delay(100);
      readKey = analogRead(0);
    }
    button = evaluateButton(readKey);
    switch (button) {
      case 4:  // This case will execute if the "back" button is pressed
        button = 0;
        activeButton = 1;
        break;
    }
  }
}

Why guess?

Didn't the compiler tell you?

  while (1)
  {
    DateTime now = rtc.now(); //Attaches now to action1 scope
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print(now.hour(), DEC);
    lcd.print(':');
    lcd.print(now.minute(), DEC);
    lcd.print(':');
    lcd.print(now.second(), DEC);
    delay(1000);
  }

How will the program ever exit this while loop ?

its almost working as I would like so now I can go to menuItem4 which its the Clock but can't go back to main menu all other menus working correctly.Thanks

Yes, of course you can't go back to the main menu. You entered an endless loop with while(1).

ok while 1 its action1 could you please help to resolve this issue as I just started Learning code.Thanks

while (activeButton == 0)?

if button not pressed , than case 4 to go back to menu if back button pressed

or maybe there is other option to call RtC to menuItem4?Thanks

daroj:
ok while 1 its action1 could you please help to resolve this issue as I just started Learning code.Thanks

You started with working code, so just go back to it. Copy another menuItem that works.

yes you right ....sorry so lets try find out possible solution.thanks in advance

can't copy another item as only this one have function added to achieve to show RTC in that menu the rest working fine without that function , I can display time without but than clocks not moving forward (not updating live),Thanks

It's unfortunate that your editor doesn't work. I don't know how to help you with that.

so do you think its because my editor time its not moving forward ? will try to compile on older version

Oh, good! Your editor works. So copy again one of the other menuItem blocks, and then paste your RTC code into it. When you're done, test it and post the revised sketch if it doesn't work.

"time is frozen". Not enough information.

ok so when going in to menuItem4 ("Clock") I can see the time but seconds not counting (frozen) when moving back to menu and after 2 sec going back to menuItem4 I can see time was changed by that 2 sec , if you know what I mean

You need to explain to us, in which part of your 15k program, it should be counting time.

ok so what I would like to achieve its to view real time clock inside menuItem4, rest of submenus will be used for my different functions, Thanks

so in other words just normal clock to show timeunder that menu