2 Digital Pins & 4 States = 4 Messages on LCD. Nearly done but need some advise?

Hello,
I am new to the forum and new to Arduino and have been hacking away at this code and doing lots of research with good results but need a little help please?

I am using a Mega 2560 with a 4 line LCD display and trying to do the following:
Using Digital Inputs (currently set to "Input_Pullup" but may need to be changed as it is looking at High & Low now) Pins 22 & 24 to display one of 4 messages on an LCD display.

The 4 states are:
State 1: = Pin 22 High; Pin 24 Low = Message 1 Line 1
State 2: = Pin 22 Low; Pin 24 High = Message 2 Line 1
State 3: = Pin 22 Low; Pin 24 Low = Message 3 Line 2
State 4: = Pin 22 High; Pin 24 High = Message 4 Line 2

I don't have an issue getting States 1 & 2 to work as per the code but States 3 & 4 ...Not sure?
I cant use more than 2 pins to achieve this as it is interfacing with a relay output from a Transmitter (fixed outputs).
I have looked at many code examples including "If" statements and "arrays" but not sure?

I have included my code below which works with states 1 & 2 for reference.

thank you

Mat

                                                         #include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
            //lcd(rs, rw, en, d4, d5, d6,d7);

void setup()
{
  for(int i=0;i<NO_OF_RELAYS;i++)
  {
    pinMode(relayPin[i],INPUT_PULLUP);
  }
  
  lcd.begin(20,4);
  lcd.clear();
  lcd.setCursor(1,0); //First Row, 7th Column
  lcd.print("Test Pins");
  delay(1000); //Pause for 2 Seconds
  lcd.clear();
}

#define NO_OF_RELAYS 4
#define PULL_DOWN 0
#define PULL_UP 1

String line1msg1 = "Line 1 MSG1";
String line1msg2 = "Line 1 MSG2";
String line2msg1 = "Line 2 MSG3";
String line2msg2 = "Line 2 MSG4";

           
int relayPin[NO_OF_RELAYS]={24,26};

boolean pinStatusPrevious[NO_OF_RELAYS]={0,0};
boolean pinStatusNow[NO_OF_RELAYS]={0,0};

void loop()
{
  for(int id=0;id<NO_OF_RELAYS;id++)
  {
    pinStatusNow[id]=digitalRead(relayPin[id]);
    ////////////
    //if(pinStatusNow[id] != pinStatusPrevious[id])
    {
      updateMessage(id,pinStatusNow[id])
      pinStatusPrevious[id]=pinStatusNow[id];
    }
  }
}

void updateMessage(int lineNumber, boolean messageNumber)
{
  switch(lineNumber)
  {
    case 0:
      lcd.setCursor(0,0); //First row first column
      if(messageNumber==PULL_DOWN)
      {
        lcd.print(line1msg1);
      }
      
     break;
             
    case 1:
      lcd.setCursor(0,0); //First row first column
      if(messageNumber==PULL_DOWN)
      {
        lcd.print(line1msg2);
      }
      break;
      
    case 2:
      lcd.setCursor(0,1); //First row first column
      if(messageNumber==PULL_DOWN)
      {
        lcd.print(line1msg3);
      }
      break;
      
     case 3:
       lcd.setCursor(0,1); //First row first column
      if(messageNumber==PULL_DOWN)
      {
        lcd.print(line1msg4);
      }
      break;    
      
  }
}
 case 1:
      lcd.setCursor(0,0); //First row first column
      if(messageNumber==PULL_DOWN)
      {
        lcd.print(line1msg2);
      }
      break;
      
    case 2:
      lcd.setCursor(0,1); //First row first column
      if(messageNumber==PULL_DOWN)
      {
        lcd.print(line1msg3);
      }
      break;

check this line in your switch case, This might be problem

Thanks for fast reply AMPS-N,

Yes the code was incorrect and re-posted below, unfortunately I still need a way to address the 2 input = 4 messages scenario though?

cheers

Mat

 #include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
            //lcd(rs, rw, en, d4, d5, d6,d7);

void setup()
{
  for(int i=0;i<NO_OF_RELAYS;i++)
  {
    pinMode(relayPin[i],INPUT_PULLUP);
  }
  
  lcd.begin(20,4);
  lcd.clear();
  lcd.setCursor(1,0); //First Row, 7th Column
  lcd.print("Test Pins");
  delay(1000); //Pause for 2 Seconds
  lcd.clear();
}

#define NO_OF_RELAYS 4
#define PULL_DOWN 0
#define PULL_UP 1

String line1msg1 = "Line 1 MSG1";
String line1msg2 = "Line 1 MSG2";
String line2msg1 = "Line 2 MSG1";
String line2msg2 = "Line 2 MSG2";

           
int relayPin[NO_OF_RELAYS]={24,26};

boolean pinStatusPrevious[NO_OF_RELAYS]={0,0};
boolean pinStatusNow[NO_OF_RELAYS]={0,0};

void loop()
{
  for(int id=0;id<NO_OF_RELAYS;id++)
  {
    pinStatusNow[id]=digitalRead(relayPin[id]);
    ////////////
    //if(pinStatusNow[id] != pinStatusPrevious[id])
    {
      updateMessage(id,pinStatusNow[id])
      pinStatusPrevious[id]=pinStatusNow[id];
    }
  }
}

void updateMessage(int lineNumber, boolean messageNumber)
{
  switch(lineNumber)
  {
    case 0:
      lcd.setCursor(0,0); //First row first column
      if(messageNumber==PULL_DOWN)
      {
        lcd.print(line1msg1);
      }
      
     break;
             
    case 1:
      lcd.setCursor(0,0); //First row first column
      if(messageNumber==PULL_DOWN)
      {
        lcd.print(line1msg2);
      }
      break;
      
    case 2:
      lcd.setCursor(0,1); //Second row first column
      if(messageNumber==PULL_DOWN)
      {
        lcd.print(line2msg1);
      }
      break;
      
     case 3:
       lcd.setCursor(0,1); //Second row first column
      if(messageNumber==PULL_DOWN)
      {
        lcd.print(line2msg2);
      }
      break;    
      
  }
}

I still Not understand problem here. Let me what ur facing now. Which problem being solved

int systemState = (digitalRead(button1) * 2) + digitalRead(button2);

systemState will have a value of 0, 1 , 2 or 3 depending on which combination of buttons are pressed. Use that in switch/case to display the relevant message but don't forget to clear the screen if the value changes so that the previous message is removed.