lcd menu screens keep jumping while integers are being changed

Hello all

I need some help debugging my code as it seems to work to a point. The code is some basic lcd screens that have different functions, a couple of the screens have intigers that can be changed and saved to eeprom.
Currently, it works fine when you use the up and down buttons to scroll through the options in the menu and will options. Once in a sub menu, when I use the up and down buttons to adjust the integers I’m finding that I suddenly get kicked out of the sub menu and back to the main menu before I can save anything. When I then try to enter back into one of the sub menus the LCD screen then goes blank. Any ideas on why this might be happening?

#include <EEPROM.h>
#include <LiquidCrystal_I2C.h>

const int up=6;
const int down =7;
const int save =8;
const int test =11;
const int back =12;



int screenCounter = 0;
int testbutcounter = 0;

LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~EEPROM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int eeAddressBoiler = 0; //EEPROM address to start reading from
int boilerTarget = 000;
int countTemp = EEPROM.get(eeAddressBoiler, boilerTarget);

int eeAddressSteam = 4;
int steamTarget = 000;
int countSteam = EEPROM.get(eeAddressSteam, steamTarget);


void memoryClear(){

  lcd.setCursor(0, 0);
  lcd.print("Memory Reset Press");
  lcd.setCursor(0, 1);
  lcd.print("Up & Save to Clear");
  lcd.setCursor(0, 2);
  lcd.print("OR Up & Down to Exit");
  
  if (digitalRead(up) == LOW && digitalRead(save) == LOW){
   for (int i = 0 ; i < EEPROM.length() ; i++) 
    EEPROM.write(i, 0);
    lcd.setCursor(0, 3);
    lcd.print("Memory Cleared");
  }


}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


void boilertempSetting() {

  lcd.setCursor(0, 0);
  lcd.print("Boiler Target Temp");
  lcd.setCursor(0, 1);
  lcd.print("C=");
  lcd.setCursor(3, 1);
  lcd.print(countTemp);
  lcd.setCursor(0, 2);
  lcd.print("Press Save to Save  ");
  lcd.setCursor(0, 3);
  lcd.print("To Exit press back  ");

  if (countTemp > 148 || countTemp < 0) {
    countTemp = 0;
  }

  if (countTemp < 10) {
    lcd.setCursor(4, 1);
    lcd.print(" ");
  }
  if (countTemp < 100) {
    lcd.setCursor(5, 1);
    lcd.print(" ");
  }
  if (digitalRead(up) == LOW)
  {
    countTemp ++;                  // Increment Count by 1
    lcd.setCursor(3, 1);
    lcd.print(countTemp);
    delay(400);
  }
  if (digitalRead(down) == LOW)
  {
    countTemp --;                   // Decrement Count by 1
    if (countTemp < 0)
      countTemp = 0;
    lcd.setCursor(3, 1);
    lcd.print(countTemp);
    delay(400);
  }
  if (digitalRead(save) == LOW)
  {
    EEPROM.put(eeAddressBoiler, countTemp);
    lcd.setCursor(7, 1);
    lcd.print("Saved");
  }
  if (digitalRead(back) == LOW)
  {
    screenCounter = 0;
    testbutcounter = 0;
  }
}

void steamtempSetting() {

  lcd.setCursor(0, 0);
  lcd.print("Steam Target Temp");
  lcd.setCursor(0, 1);
  lcd.print("C=");
  lcd.setCursor(3, 1);
  lcd.print(countSteam);
  lcd.setCursor(0, 2);
  lcd.print("Press Save to Save  ");
  lcd.setCursor(0, 3);
  lcd.print("To Exit press back  ");

  if (countSteam < 10) {
    lcd.setCursor(4, 1);
    lcd.print(" ");
  }
  if (countTemp < 100) {
    lcd.setCursor(5, 1);
    lcd.print(" ");
  }
  if (countSteam > 148 || countSteam < 0) {
    countSteam = 0;
  }

  if (digitalRead(up) == LOW)
  {
    countSteam = countSteam + 1;                  // Increment Count by 1
    lcd.setCursor(3, 1);
    lcd.print(countSteam);
    delay(400);
  }

  if (digitalRead(down) == LOW)
  {
    countSteam = countSteam - 1;                   // Decrement Count by 1
    if (countSteam < 0)
      countSteam = 0;
    lcd.setCursor(3, 1);
    lcd.print(countSteam);
    delay(400);
  }
  if (digitalRead(save) == LOW)
  {
    EEPROM.put(eeAddressSteam, countSteam);
    lcd.setCursor(7, 1);
    lcd.print("Saved");
  }
  if (digitalRead(back) == LOW)
  {
    screenCounter = 0;
    testbutcounter = 0;
  }
}


void testScreens() {

  Serial.print(screenCounter);
  Serial.println(testbutcounter);
  
   if (testbutcounter > 2 || testbutcounter < 0 ) {
    testbutcounter = 0;
  }

  if (screenCounter > 4 || screenCounter < 0) {
    screenCounter = 0;
  }

  if (digitalRead(up) == LOW)
  {
    screenCounter ++;                  // Increment Count by 1
    delay(400);
  }
  if (digitalRead(down) == LOW)
  {
    screenCounter --;                   // Decrement Count by 1
    if (screenCounter < 0)
      countTemp = 0;
    delay(400);
  }

  enum screens { TEST, BOILERTARG, BOILERTARGA, STEAMTARG, STEAMTARGA };
  int currentScreen = -1;


  if ( currentScreen != TEST && screenCounter == 0 ) {
    testmenu();
    currentScreen = TEST;
  }

  if  ( currentScreen != BOILERTARG && screenCounter == 1 ) {
    boiler();
    currentScreen = BOILERTARG;
    if (digitalRead (test) == LOW) {
    testbutcounter ++;
    screenCounter ++;
    lcd.clear();
  }
  }
  if (currentScreen != BOILERTARGA && screenCounter == 2 && testbutcounter == 1) {
    boilerA();
    currentScreen = BOILERTARGA;
   
  }
 if( currentScreen != STEAMTARG && screenCounter == 3 ) {
    steam();
    currentScreen = STEAMTARG;
    if (digitalRead (test) == LOW) {
    testbutcounter ++;
    screenCounter ++;
    lcd.clear();
  }
 }
 if (currentScreen != STEAMTARGA && screenCounter == 4 && testbutcounter == 1) {
    steamA();
    currentScreen = STEAMTARGA;
 }
}

void testmenu() {
  lcd.setCursor(0, 0);
  lcd.print("Cleaning & Setup    ");
  lcd.setCursor(0, 1);
  lcd.print ("Use UP & Down       ");
  lcd.setCursor(0, 2);
  lcd.print ("                    ");
  lcd.setCursor(0, 3);
  lcd.print("To Navigate         ");
}
void boiler() {
  lcd.setCursor(0, 0);
  lcd.print("Boiler Target       ");
  lcd.setCursor(0, 1);
  lcd.print("To change the target");
  lcd.setCursor(0, 2);
  lcd.print("temp of the boiler");
  lcd.setCursor(0, 3);
  lcd.print("Press test to enter");
  
}

void boilerA() {
   
    boilertempSetting();

  }

  void steam() {
    lcd.setCursor(0, 0);
    lcd.print("Steam Target        ");
    lcd.setCursor(0, 1);
    lcd.print("To change the target");
    lcd.setCursor(0, 2);
    lcd.print("temp of the steam  ");
    lcd.setCursor(0, 3);
    lcd.print("Press test to enter");
  }
  void steamA(){
    
    steamtempSetting();
  }
void setup() {
Serial.begin(9600);
lcd.begin(20, 4);        // initialize the lcd for 20 chars 4 lines
lcd.backlight();         // Turns backlight LCD on
pinMode (up,INPUT_PULLUP);
digitalWrite (up,HIGH);
pinMode (down,INPUT_PULLUP);
digitalWrite (down,HIGH);
pinMode (save,INPUT_PULLUP);
digitalWrite (save,HIGH);
pinMode (test,INPUT_PULLUP);
digitalWrite (test,HIGH);
pinMode (back,INPUT_PULLUP);
digitalWrite (back,HIGH);

}

void loop() {


  testScreens();

}
  pinMode (up, INPUT_PULLUP);
  digitalWrite (up, HIGH);

Why do you have the digitalWrite() here ? The INPUT_PULLUP in pinMode() will have already taken the pin HIGH.

Thank you UKHeliBob

my bad the pin is already high do you think this could be whats causing the menu screens to jump?

do you think this could be whats causing the menu screens to jump?

Probably not but I spotted it when looking to see whether INPUT_PULLUP was being used. I am not sure what the effect of it is but probably none, it just looks odd.

I have removed it and it digitawrite() and its still the same

I have also noticed if i hold down either the up or down button that also makes the current screen jump to another screen

  lcd.print(countTemp);

What, EXACTLY, are you counting? Temperatures? How would THAT make sense?

  lcd.print(countSteam);

Now you are counting steams? How does THAT make sense?

  Serial.print(screenCounter);
  Serial.println(testbutcounter);

You REALLY need to come up with meaningful names. Not every variable needs to have count in it somewhere.

Sometimes number makes more sense than count.

Hello PaulS

countTemp and countSteam are integers that are increased or decreased and then saved to eeprom then eventually used to preset a target temperature for a boiler for code i have not yet written.

What, EXACTLY, are you counting? Temperatures? How would THAT make sense?

Serial.print(screenCounter);
Serial.println(testbutcounter); allow me to check that the correct integer has been saved.

You REALLY need to come up with meaningful names. Not every variable needs to have count in it somewhere.

It does if i have a massive sketch with multiple names close to steam or Temp!!

So still none the wiser for why it jumps out of the menu!

countTemp and countSteam are integers that are increased or decreased and then saved to eeprom then eventually used to preset a target temperature for a boiler for code i have not yet written.

So, they don't really count anything. Hmmm. I suppose you have a cat named dog, too.

It does if i have a massive sketch with multiple names close to steam or Temp!!

The names do NOT have to have count in them if the purpose is not to count things.
YouAreAllowedToUseReallyLongNamesIfDoingSoMakesSense.

So still none the wiser for why it jumps out of the menu!

I haven't seen a schematic or even a description of how the switch(es) is(are) wired.

Thank you PaulS

I have taken what you have said on board and edited the code and have uploaded a hand drawn wiring diagram.

#include <EEPROM.h>
#include <LiquidCrystal_I2C.h>

const int up = 6;
const int down = 7;
const int save = 8;
const int test = 11;
const int back = 12;


int screenNumber = 0;
int testbutNumberoftimespressed = 0;

LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~EEPROM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int eeAddressBoiler = 0; //EEPROM address to start reading from
int boilerTarget = 000;
int boilertargetnumber = EEPROM.get(eeAddressBoiler, boilerTarget);

int eeAddressSteam = 4;
int steamTarget = 000;
int steamTargetnumber = EEPROM.get(eeAddressSteam, steamTarget);


void memoryClear() {

  lcd.setCursor(0, 0);
  lcd.print("Memory Reset Press");
  lcd.setCursor(0, 1);
  lcd.print("Up & Save to Clear");
  lcd.setCursor(0, 2);
  lcd.print("OR Up & Down to Exit");

  if (digitalRead(up) == LOW && digitalRead(save) == LOW) {
    for (int i = 0 ; i < EEPROM.length() ; i++)
      EEPROM.write(i, 0);
    lcd.setCursor(0, 3);
    lcd.print("Memory Cleared");
  }

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ boiler tamp settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


void boilertempSetting() {

  lcd.setCursor(0, 0);
  lcd.print("Boiler Target Temp");
  lcd.setCursor(0, 1);
  lcd.print("C=");
  lcd.setCursor(3, 1);
  lcd.print(boilertargetnumber);
  lcd.setCursor(0, 2);
  lcd.print("Press Save to Save  ");
  lcd.setCursor(0, 3);
  lcd.print("To Exit press back  ");

  if (boilertargetnumber > 148 || boilertargetnumber < 0) {
    boilertargetnumber = 0;
  }

  if (boilertargetnumber < 10) {
    lcd.setCursor(4, 1);
    lcd.print(" ");
  }
  if (boilertargetnumber < 100) {
    lcd.setCursor(5, 1);
    lcd.print(" ");
  }
  if (digitalRead(up) == LOW)
  {
    boilertargetnumber ++;                  // Increment Count by 1
    lcd.setCursor(3, 1);
    lcd.print(boilertargetnumber);
    delay(400);
  }
  if (digitalRead(down) == LOW)
  {
    boilertargetnumber --;                   // Decrement Count by 1
    if (boilertargetnumber < 0) {
      boilertargetnumber = 0;
    }
    lcd.setCursor(3, 1);
    lcd.print(boilertargetnumber);
    delay(400);
  }
  if (digitalRead(save) == LOW)
  {
    EEPROM.put(eeAddressBoiler, boilerTarget);
    lcd.setCursor(7, 1);
    lcd.print("Saved");
  }
  if (digitalRead(back) == LOW)
  {
    screenNumber = 0;
    testbutNumberoftimespressed = 0;
  }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steam tamp settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void steamtempSetting() {

  lcd.setCursor(0, 0);
  lcd.print("Steam Target Temp");
  lcd.setCursor(0, 1);
  lcd.print("C=");
  lcd.setCursor(3, 1);
  lcd.print(steamTargetnumber);
  lcd.setCursor(0, 2);
  lcd.print("Press Save to Save  ");
  lcd.setCursor(0, 3);
  lcd.print("To Exit press back  ");

  if (steamTargetnumber < 10) {
    lcd.setCursor(4, 1);
    lcd.print(" ");
  }
  if (steamTargetnumber < 100) {
    lcd.setCursor(5, 1);
    lcd.print(" ");
  }
  if (steamTargetnumber > 148 || steamTargetnumber < 0) {
    steamTargetnumber = 0;
  }

  if (digitalRead(up) == LOW)
  {
    steamTargetnumber ++;                  // Increment Count by 1
    lcd.setCursor(3, 1);
    lcd.print(steamTargetnumber);
    delay(400);
  }

  if (digitalRead(down) == LOW)
  {
    steamTargetnumber --;                   // Decrement Count by 1
    if (steamTargetnumber < 0) {
      steamTargetnumber = 0;
    }
    lcd.setCursor(3, 1);
    lcd.print(steamTargetnumber);
    delay(400);
  }
  if (digitalRead(save) == LOW)
  {
    EEPROM.put(eeAddressSteam, steamTarget);
    lcd.setCursor(7, 1);
    lcd.print("Saved");
  }
  if (digitalRead(back) == LOW)
  {
    screenNumber = 0;
    testbutNumberoftimespressed = 0;
  }

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test screens  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void testScreens() {

  Serial.print(screenNumber);
  Serial.println(testbutNumberoftimespressed);

  if (testbutNumberoftimespressed > 2 || testbutNumberoftimespressed < 0 ) {
    testbutNumberoftimespressed = 0;
  }

  if (screenNumber > 4 || screenNumber < 0) {
    screenNumber = 0;
  }

  if (digitalRead(up) == LOW)
  {
    screenNumber ++;                  // Increment Count by 1
    delay(400);
  }
  if (digitalRead(down) == LOW)
  {
    screenNumber --;                  // Decrement Count by 1
    if (screenNumber < 0)
      screenNumber = 0;
    delay(400);
  }

  enum screens { TEST, BOILERTARGET, BOILERTARGETSET, STEAMTARGET, STEAMTARGETSET };
  int currentScreen = -1;


  if ( currentScreen != TEST && screenNumber == 0 ) {
    testmenu();
    currentScreen = TEST;
  }

  if  ( currentScreen != BOILERTARGET && screenNumber == 1 ) {
    boiler();
    currentScreen = BOILERTARGET;
    if (digitalRead (test) == LOW) {
      testbutNumberoftimespressed ++;
      screenNumber ++;
      lcd.clear();
    }
  }
  if (currentScreen != BOILERTARGETSET && screenNumber == 2 && testbutNumberoftimespressed == 1) {
    boilerSettingmenu();
    currentScreen = BOILERTARGETSET;

  }

  if ( currentScreen != STEAMTARGET && screenNumber == 3 ) {
    steam();
    currentScreen = STEAMTARGET;
    if (digitalRead (test) == LOW) {
      testbutNumberoftimespressed ++;
      screenNumber ++;
      lcd.clear();
    }
  }
  if (currentScreen != STEAMTARGETSET && screenNumber == 4 && testbutNumberoftimespressed == 1) {
    steamSettingsmenu();
    currentScreen = STEAMTARGETSET;
  }
}

void testmenu() {
  lcd.setCursor(0, 0);
  lcd.print("Cleaning & Setup    ");
  lcd.setCursor(0, 1);
  lcd.print ("Use UP & Down       ");
  lcd.setCursor(0, 2);
  lcd.print ("                    ");
  lcd.setCursor(0, 3);
  lcd.print("To Navigate         ");
}
void boiler() {
  lcd.setCursor(0, 0);
  lcd.print("Boiler Target       ");
  lcd.setCursor(0, 1);
  lcd.print("To change the target");
  lcd.setCursor(0, 2);
  lcd.print("temp of the boiler");
  lcd.setCursor(0, 3);
  lcd.print("Press test to enter");

}

void boilerSettingmenu() {

  boilertempSetting();

}

void steam() {
  lcd.setCursor(0, 0);
  lcd.print("Steam Target        ");
  lcd.setCursor(0, 1);
  lcd.print("To change the target");
  lcd.setCursor(0, 2);
  lcd.print("temp of the steam  ");
  lcd.setCursor(0, 3);
  lcd.print("Press test to enter");
}
void steamSettingsmenu() {

  steamtempSetting();
}
void setup() {
  Serial.begin(9600);
  lcd.begin(20, 4);        // initialize the lcd for 20 chars 4 lines
  lcd.backlight();         // Turns backlight LCD on
  pinMode (up, INPUT_PULLUP);
  pinMode (down, INPUT_PULLUP);
  pinMode (save, INPUT_PULLUP);
  pinMode (test, INPUT_PULLUP);
  pinMode (back, INPUT_PULLUP);


}

void loop() {


  testScreens();

}

I guess I am missing something. In boilertempSetting(), you increment or decrement, and constrain, boilertargetnumber, which seems reasonable. But, then, if the save switch is pressed, you save boilerTarget to EEPROM. boilerTarget has not been assigned a new value, so you are saving 0 to EEPROM. I don't get it.

The same stuff happens in steamtempSetting().

void loop() {


  testScreens();

}

The ONLY reason for putting the { on the line with the statement/function that holds ANY water is to save real-estate. You look pretty stupid then using all that white space in the function. That is NOT the impression you are aiming for, is it?

Thank you

I have updated the code and tested it. It saves the correct integer for both steam and boiler.
It still jumps about while holding the up or down buttons or tapping them to quickly while changing the integer all the other buttons are fine.

#include <EEPROM.h>
#include <LiquidCrystal_I2C.h>

const int up = 6;
const int down = 7;
const int save = 8;
const int test = 11;
const int back = 12;


int screenNumber = 0;
int testbutNumberoftimespressed = 0;

LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~EEPROM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int eeAddressBoiler = 0; //EEPROM address to start reading from
int boilerTarget = 000;
int boilertargetnumber = EEPROM.get(eeAddressBoiler, boilerTarget);

int eeAddressSteam = 4;
int steamTarget = 000;
int steamTargetnumber = EEPROM.get(eeAddressSteam, steamTarget);


void memoryClear() {

  lcd.setCursor(0, 0);
  lcd.print("Memory Reset Press");
  lcd.setCursor(0, 1);
  lcd.print("Up & Save to Clear");
  lcd.setCursor(0, 2);
  lcd.print("OR Up & Down to Exit");

  if (digitalRead(up) == LOW && digitalRead(save) == LOW) {
    for (int i = 0 ; i < EEPROM.length() ; i++)
      EEPROM.write(i, 0);
    lcd.setCursor(0, 3);
    lcd.print("Memory Cleared");
  }

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ boiler tamp settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


void boilertempSetting() {

  lcd.setCursor(0, 0);
  lcd.print("Boiler Target Temp");
  lcd.setCursor(0, 1);
  lcd.print("C=");
  lcd.setCursor(3, 1);
  lcd.print(boilertargetnumber);
  lcd.setCursor(0, 2);
  lcd.print("Press Save to Save  ");
  lcd.setCursor(0, 3);
  lcd.print("To Exit press back  ");

  if (boilertargetnumber > 148 || boilertargetnumber < 0) {
    boilertargetnumber = 0;
  }

  if (boilertargetnumber < 10) {
    lcd.setCursor(4, 1);
    lcd.print(" ");
  }
  if (boilertargetnumber < 100) {
    lcd.setCursor(5, 1);
    lcd.print(" ");
  }
  if (digitalRead(up) == LOW)
  {
    boilertargetnumber ++;                  // Increment Count by 1
    lcd.setCursor(3, 1);
    lcd.print(boilertargetnumber);
    delay(400);
  }
  if (digitalRead(down) == LOW)
  {
    boilertargetnumber --;                   // Decrement Count by 1
    if (boilertargetnumber < 0) {
      boilertargetnumber = 0;
    }
    lcd.setCursor(3, 1);
    lcd.print(boilertargetnumber);
    delay(400);
  }
  if (digitalRead(save) == LOW)
  {
    EEPROM.put(eeAddressBoiler, boilertargetnumber);
    lcd.setCursor(7, 1);
    lcd.print("Saved");
  }
  if (digitalRead(back) == LOW)
  {
    screenNumber = 0;
    testbutNumberoftimespressed = 0;
  }
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steam tamp settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void steamtempSetting() {

  lcd.setCursor(0, 0);
  lcd.print("Steam Target Temp");
  lcd.setCursor(0, 1);
  lcd.print("C=");
  lcd.setCursor(3, 1);
  lcd.print(steamTargetnumber);
  lcd.setCursor(0, 2);
  lcd.print("Press Save to Save  ");
  lcd.setCursor(0, 3);
  lcd.print("To Exit press back  ");

  if (steamTargetnumber < 10) {
    lcd.setCursor(4, 1);
    lcd.print(" ");
  }
  if (steamTargetnumber < 100) {
    lcd.setCursor(5, 1);
    lcd.print(" ");
  }
  if (steamTargetnumber > 148 || steamTargetnumber < 0) {
    steamTargetnumber = 0;
  }

  if (digitalRead(up) == LOW)
  {
    steamTargetnumber ++;                  // Increment Count by 1
    lcd.setCursor(3, 1);
    lcd.print(steamTargetnumber);
    delay(400);
  }

  if (digitalRead(down) == LOW)
  {
    steamTargetnumber --;                   // Decrement Count by 1
    if (steamTargetnumber < 0) {
      steamTargetnumber = 0;
    }
    lcd.setCursor(3, 1);
    lcd.print(steamTargetnumber);
    delay(400);
  }
  if (digitalRead(save) == LOW)
  {
    EEPROM.put(eeAddressSteam, steamTargetnumber);
    lcd.setCursor(7, 1);
    lcd.print("Saved");
  }
  if (digitalRead(back) == LOW)
  {
    screenNumber = 0;
    testbutNumberoftimespressed = 0;
  }

}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test screens  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void testScreens() {

  Serial.print(screenNumber);
  Serial.println(testbutNumberoftimespressed);

  if (testbutNumberoftimespressed > 2 || testbutNumberoftimespressed < 0 ) {
    testbutNumberoftimespressed = 0;
  }

  if (screenNumber > 4 || screenNumber < 0) {
    screenNumber = 0;
  }

  if (digitalRead(up) == LOW)
  {
    screenNumber ++;                  // Increment Count by 1
    delay(400);
  }
  if (digitalRead(down) == LOW)
  {
    screenNumber --;                  // Decrement Count by 1
    if (screenNumber < 0)
      screenNumber = 0;
    delay(400);
  }

  enum screens { TEST, BOILERTARGET, BOILERTARGETSET, STEAMTARGET, STEAMTARGETSET };
  int currentScreen = -1;


  if ( currentScreen != TEST && screenNumber == 0 ) {
    testmenu();
    currentScreen = TEST;
  }

  if  ( currentScreen != BOILERTARGET && screenNumber == 1 ) {
    boiler();
    currentScreen = BOILERTARGET;
    if (digitalRead (test) == LOW) {
      testbutNumberoftimespressed ++;
      screenNumber ++;
      lcd.clear();
    }
  }
  if (currentScreen != BOILERTARGETSET && screenNumber == 2 && testbutNumberoftimespressed == 1) {
    boilerSettingmenu();
    currentScreen = BOILERTARGETSET;

  }

  if ( currentScreen != STEAMTARGET && screenNumber == 3 ) {
    steam();
    currentScreen = STEAMTARGET;
    if (digitalRead (test) == LOW) {
      testbutNumberoftimespressed ++;
      screenNumber ++;
      lcd.clear();
    }
  }
  if (currentScreen != STEAMTARGETSET && screenNumber == 4 && testbutNumberoftimespressed == 1) {
    steamSettingsmenu();
    currentScreen = STEAMTARGETSET;
  }
}

void testmenu() {
  lcd.setCursor(0, 0);
  lcd.print("Cleaning & Setup    ");
  lcd.setCursor(0, 1);
  lcd.print ("Use UP & Down       ");
  lcd.setCursor(0, 2);
  lcd.print ("                    ");
  lcd.setCursor(0, 3);
  lcd.print("To Navigate         ");
}
void boiler() {
  lcd.setCursor(0, 0);
  lcd.print("Boiler Target       ");
  lcd.setCursor(0, 1);
  lcd.print("To change the target");
  lcd.setCursor(0, 2);
  lcd.print("temp of the boiler");
  lcd.setCursor(0, 3);
  lcd.print("Press test to enter");

}

void boilerSettingmenu() {

  boilertempSetting();

}

void steam() {
  lcd.setCursor(0, 0);
  lcd.print("Steam Target        ");
  lcd.setCursor(0, 1);
  lcd.print("To change the target");
  lcd.setCursor(0, 2);
  lcd.print("temp of the steam  ");
  lcd.setCursor(0, 3);
  lcd.print("Press test to enter");
}
void steamSettingsmenu() {

  steamtempSetting();
}
void setup() {
  Serial.begin(9600);
  lcd.begin(20, 4);        // initialize the lcd for 20 chars 4 lines
  lcd.backlight();         // Turns backlight LCD on
  pinMode (up, INPUT_PULLUP);
  pinMode (down, INPUT_PULLUP);
  pinMode (save, INPUT_PULLUP);
  pinMode (test, INPUT_PULLUP);
  pinMode (back, INPUT_PULLUP);


}

void loop() {


  testScreens();

}

As for the rest of your statement - I appreciate that my code isn’t right and might not be the tidiest. I am self taught and I come here for help. I really don’t appreciate being spoken down to all the time. Constantly being belittled for not getting things right is very off putting and unnecessary. If I was a kid trying to teach myself but every time I needed help I was treated in that manner I may never want to come back. I think we should try and encourage as many people to get into this stuff as possible so let’s try and be a little bit more patient with each other please!