programming keypad menu and display on 16x2 LCD

Dear all

I’m very new for arduino and trying to program keypad menu. I have to program menu and sub-menu.
I wrote and tested my code, it runs without error; however, the result is not what I expected.

I used 43 keypad, 162 lcd and one arduino nano.

here’s the code

#include <Wire.h>
#include <LiquidCrystal.h>
#include <Key.h>
#include <Keypad.h>

#define Startup 0
#define Mainmenu 1
#define Checkmode 2
#define Phaseshift 3
#define CV 4
#define CC 5
#define Remote 6

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
    {'1','2','3'},
    {'4','5','6'},
    {'7','8','9'},
    {'*','0','#'}
};

byte rowPins[ROWS] = {8,7,6,5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4,3,2}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
//const int rs = A5, en = A4, d4 = A3, d5 = A2, d6 = A1, d7 = A0;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);


// ************************declare variables***************************
// startup
byte mode = Startup;
char entry1 = keypad.getKey();

//backspace
String Line1 = "                ";
String Line2 = "                ";
char cursors = 0;

//phaseshift
char phase_value[2];
int phase_cursor;
int phase_index;
char phasesign;

//declare function
void Phaseshift_Fn();
void CV_Fn();
void CC_Fn();
void Remote_Fn();

void loop()
{

}

void setup()
{
  Serial.begin(9600);
  lcd.begin(16,2);
  lcd.clear();
  lcd.setCursor(0, 0); lcd.print(Line1);
  lcd.setCursor(0, 1); lcd.print(Line2);
  delay(100);

  mainfunction();
}

// *********************************startup************************************

void mainfunction()
{
  
  switch(mode)
{
  case Startup:
    lcd.begin(16,2);
    lcd.clear();
    lcd.setCursor(0,0);
    Line1 = "Ready, choose";
    lcd.print(Line1);
    lcd.setCursor(0,1);
    Line2 = "input mode";
    lcd.print(Line2);
    delay(1000);
    mode = Mainmenu;
    mainfunction();
    break;

//******problem is here **********************
    
  case Mainmenu:
    //char entry1 = keypad.getKey();
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Input");
    lcd.setCursor(0,1);
    lcd.print("Mode:             ");

    if (entry1 == '0','1','2','3','4','5','6','7','8','9')
    {
      Line2[cursors] = entry1; cursors++;
      lcd.print(entry1);
      Serial.println(entry1);
      break;
    }

    else if (entry1 == '*')         //backspace
    {
        if (cursors >0) 
      {
        cursors--;
        Line2[cursors] = ' '; 
        break; 
      }
    }

    else if(entry1 == '#')           //press enter
    {
      mode = Checkmode;
      mainfunction();
    }
    break;

//***********************************************

case Checkmode:                   //check the values
  
      if(entry1 == '0')
      {
        lcd.clear();
        lcd.setCursor(0,1);
        lcd.print("Phase Shift");
        delay(1000);
        mode = Phaseshift;
        break;
      }

      else if(entry1 == '1')
      {
        lcd.clear();
        lcd.setCursor(0,1);
        lcd.print("Constant Voltage");
        delay(1000);
        mode = CV;
        break;
      }

      else if(entry1 == '2')
      {
        lcd.clear();
        lcd.setCursor(0,1);
        lcd.print("Constant Current");
        delay(1000);
        mode = CC;   
        break;
      }
      
      else if(entry1 == '3')
      {
        lcd.clear();
        lcd.setCursor(0,1);
        lcd.print("Remote");
        delay(1000);
        mode = Remote;
        break;
      }
      
      else
      {
        lcd.clear();
        lcd.setCursor(0,0);
        lcd.print("invalid");
        lcd.setCursor(0,1);
        lcd.print("input again");
        delay(1000);
        mode = Mainmenu;
        break;
      }
      
 case Phaseshift:
      Phaseshift_Fn();         //link to further menu
      break;

  case CV:
      CV_Fn();
      break;

  case CC:
      CC_Fn();
      break;   

  case Remote:
      Remote_Fn();
      break;  
}

}

Problem is at case Mainmenu, after I input number from keypad I want the lcd to print and show the number. After that if press ‘#’ button, it will acts like enter button and run through next step. ( ‘*’ is a backspace)

But the lcd display shows and freeze here

Input
** Mode:**

And the number I input from keypad (including ‘*’ and ‘#’ is not printed).
Not sure which part I’ve done something wrong.

Any suggestion would be really appreciated
Thank you so much in advance

char entry1 = keypad.getKey();

The compiler can't tell if a key on some other hardware is being pressed, so this is a useless initialization of the entry1 variable.

String Line1 = "                ";
String Line2 = "                ";

Put the crutches away. Stop using Strings. Period.

void loop()
{

}

So, once setup() ends, there is nothing to do. Interesting.

setup() calls mainfunction() which calls mainfunction() which calls mainfunction()... Recursions solves an extremely limited set of problems. In this case, it is just plain wrong.

You need to rethink your ENTIRE approach.