menu is not working

Hello arduino friends.

The script is too long to place it like this here. but is placed as a file

The buttons work but go wrong. Button 5 is menu but when button 5 is pressed nothing happens. button 4 is menu but that is officially right.

1 up
2 down
3 left
4 right
5 enter / back

sorry my writing english is not so good.

thanks for your help

Groentetuin.ino (12.7 KB)

Your buttons can perform functions depending which menu you're in. But your code does not quite seem to do that.

void knoppen()
{
  ...
  ...

      if (knop == 3 && menu > 0) menu--; // Hoofd menu (knop left)

  ...
  ...
      if (menu == 0) { // plaats data op display in rust
        lcd.clear();

      } else if (menu == 1) { // Menu optie 1 (Relay 1 Aan uur)

        lcd.setCursor(0, 0);
        lcd.print("Relay 1 aan ?");
        if (knop == 3 && OnHour1 > 0)  OnHour1--;

}

In the above, you use the button to both decrement the menu and OneHour1. Imagine menu is currently equal to 2 and you go through the above code. You first decrement the menu (now 1) and next decrement the OnHour1; is that what you want?

This seems to indicate a problem in the logic (and therefore might be the cause of the described problem).