button and LCD 20x4

hallo all,anyone can help me for the sketch?

if i have 8 switch,8 LED and 1 20x4 LCD...

for example :
if i hit the switch 1, led 1 is on,and lcd is on with the word. ("menu 1")
if i hit the switch 2, led 2 is on,and the lcd word change ("menu2") and so on

i use mega 256, and LCD 20x4 with I2C.

anyone can help me,?please..

Post your code, in code tags. Describe what the code actually does and how that differs from what you want it to do. We will not write code for you. We will help you get your code to work.

How is the switch wired?

What does it mean to "hit the switch"?

Should the led come on and the message appear only while the button (you called it a button in the title) is pressed and then go off / blank, or should they persist when the button is released?

Was bored so coded the following. Does the leds only, cba to dig out an lcd.

For more buttons and leds (I used 3) just add more pins to the arrays buttonPins and ledPins.

Wire buttons to ground.

// https://forum.arduino.cc/index.php?topic=650037

// uses state change detect on a button array
// 27 november 2019

/*
  for example :
  if i [wickay1979] hit the switch 1, led 1 is on,and lcd is on with the word. ("menu 1")
  if i hit the switch 2, led 2 is on,and the lcd word change ("menu2") and so on
*/

// the buttons
byte buttonPins[] = {4, 3, 11}; //the buttons must be wired from pin to ground, pinmodes are input_pullup
const byte howManyButtons(sizeof(buttonPins) / sizeof(byte));
bool buttonStates[howManyButtons];         // current state of the button
bool lastButtonStates[howManyButtons];     // previous state of the button
// and leds
byte ledPins[] = {2, 6, 7};

void setup()
{
  // initialize serial communication:
  Serial.begin(9600);
  Serial.println("setup() ... ");
  Serial.println("leds (todo: and lcd) controlled by buttons");
  Serial.println(" ");

  // initialize the button pins as input with pullup so active low
  //    make sure the button is from pin to ground
  for (int i = 0; i < howManyButtons; i++)
  {
    pinMode(buttonPins[i], INPUT_PULLUP);
    //initialize button states
    buttonStates[i] = digitalRead(buttonPins[i]);
    lastButtonStates[i] = buttonStates[i];
  }

  //pinmode the leds
  for (int i = 0; i < howManyButtons; i++)
  {
    pinMode(ledPins[i], OUTPUT);
    digitalWrite(ledPins[i], LOW);
  }

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  Serial.println("setup() done");
  Serial.println("Press a button....");
  Serial.println(" ");
}

void loop()
{
  checkForAButton();

} //loop

void checkForAButton()
{
  for (int i = 0; i < howManyButtons; i++)
  {
    buttonStates[i] = digitalRead(buttonPins[i]);
    // compare the buttonState to its previous state
    if (buttonStates[i] != lastButtonStates[i]) // means it changed... but which way?
    {
      if (buttonStates[i] == LOW)  // changed to pressed
      {
        Serial.print(i);
        Serial.println(" newly pressed");
        //easiest way to turn off the previous led is to turn them all of
        for (int j = 0; j < howManyButtons; j++)
        {
          digitalWrite(ledPins[j], LOW);
        }
        //then turn the right one one
        digitalWrite(ledPins[i], HIGH);
      }

      // ersatz de-bounce
      delay(50);
    }
    // save the current state as the last state, for next time through the loop
    lastButtonStates[i] = buttonStates[i];
  }
} // checkForAButton()