Problem with clock settings - storing dana....

Hello,

I have a problem with setting hour and minutes. I can set newhour and newmin values but they are not stored and I can not change time. Could you please let me know what I'm doing wrong? Below is fragment of the code. All state, newhour, newmin, change etc are declared correctly.

Thanks in advance
Greg

if (digitalRead(settings) == LOW) {delay(30); if(digitalRead(settings) == LOW); state = state + 1;
    newhour = dt.hour; newmin = dt.minute;
    if (state >= 4) {state == 0;}}
     if (state == 1) {
      u8g2.firstPage();
  do {
      u8g2.setFont(u8g2_font_crox3hb_tf);
      u8g2.setCursor(80, 20);
      u8g2.print("NEW TIME");
      u8g2.setCursor(40, 40);
      u8g2.print("HOUR: ");
      if (digitalRead(change) == LOW) {delay(30); if(digitalRead(change) == LOW);
      newhour = newhour + 1;
      if (newhour >23) {newhour = 0;}}
      u8g2.print(newhour);
   } while ( u8g2.nextPage() ); 
      }
     if (state == 2) {
      u8g2.firstPage();
  do {
      u8g2.setCursor(80, 20);
      u8g2.print("NEW TIME");
      u8g2.setCursor(40, 40);
      u8g2.print("MINUTES: ");
      if (digitalRead(change) == LOW) {delay(30); if(digitalRead(change) == LOW);
      newmin = newmin + 1;
      if (newmin >59) {newmin = 0;}}
      u8g2.print(newmin);
     } while ( u8g2.nextPage() ); 
     }
     if (state == 3) {
      clock.setDateTime(dt.year, dt.month, dt.day, newhour, newmin, 0);
      state = 0;}

Could you please let me know what I'm doing wrong?

Yep. You posted a snippet of code here, instead of at http://snippets-r-us.com.

    newhour = dt.hour; newmin = dt.minute;

ONE statement per line. Banging the return key won't give you herpes. Just do it.

    if (state >= 4) {state == 0;}}

EVERY } belongs on a line BY ITSELF.

What does the second misplaced } end?

Thank you. This } is the end of the first digital read:

if (digitalRead(settings) == LOW) {delay(30); if(digitalRead(settings) == LOW);
state = state + 1;
newhour = dt.hour;
newmin = dt.minute;
if (state >= 4) {state == 0;}
}

Thank you. This } is the end of the first digital read:

Put every statement on its own line. Use Tools _+ Auto Format to properly indent that mess. Post the code CORRECTLY.

Read the stickies at the top of the forum BEFORE you hit Post again.

Ok, thank you very much. That's help me a lot. Hope that I can help you in the future....