I’m doing an arduino program and I want it clear before becoming too big. For that, I want you divide the following code, bu putting all thee part concerning thee keyboard in a new « use_keyboard.h » and « use_keyboard.cpp », all the menus (with the part using LCD and keyoard) in a new « menu.h » and « menu.cpp »,:

#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DS3232RTC.h>
#include <Streaming.h>

// Pin configuration and libraries initiation
const byte ROWS = 4;
const byte COLS = 4;
// Définition des broches du clavier matriciel
byte rowPins[ROWS] = { 33, 32, 31, 30 };
byte colPins[COLS] = { 29, 28, 27, 26 };
// Définition des touches du clavier matriciel
char keys[ROWS][COLS] = {
  { '1', '2', '3', 'A' },
  { '4', '5', '6', 'B' },
  { '7', '8', '9', 'C' },
  { '*', '0', '#', 'D' }
};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd(0x27, 20, 4);
DS3232RTC rtc;

const int Relai_depart = 34;
const int NUM_RELAYS = 8;
bool relayStates[NUM_RELAYS];
int timer[NUM_RELAYS];

// Paramètre programme horaire (PH)
const int Quantite_PH = 5;
int Heure_PH[Quantite_PH] = {0};
int Min_PH[Quantite_PH] = {0};

// Variables
int relayPins[12] = { 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45 };
int buttonPin = 18;
float temp1, temp2, temp3, temp4;
float hum1, hum2, hum3, hum4;

void setup() {
  Wire.begin();
  rtc.begin();

  for (int i = 0; i < 12; i++) {
    pinMode(relayPins[i], OUTPUT);
    digitalWrite(relayPins[i], LOW);
  }

  pinMode(buttonPin, INPUT_PULLUP);
  lcd.init();
  lcd.backlight();
}

void loop() {
  if (digitalRead(buttonPin) == LOW) {
    mainMenu();
  }
}

void mainMenu() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("A-Relays  B-Info");
  lcd.setCursor(0, 1);
  lcd.print("D-Quit");

  char key = keypad.waitForKey();
  switch (key) {
    case 'A': relaysMenu(); break;
    case 'B': infoMenu(); break;
    case 'D': lcd.clear(); lcd.noBacklight(); break;
  }
}

void relaysMenu() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Enter relay #");

  // Collect relay number (1-12)
  int relay = getKeypadValue(1, 12, "Enter relay #");
  relay = relay - 1 ;
  lcd.setCursor(0, 1);
lcd.print("A:ON/OFF B:TIMER ");
lcd.setCursor(0, 2);
lcd.print("C:Program D:Exit ");

bool exitFlag = false;
while (!exitFlag) {
  char key = keypad.waitForKey();
  int value;

  switch (key) {
    case 'A':
      relayStates[relay] = !relayStates[relay];
      break;

    case 'B':
      value = getKeypadValue(0, 999, "Enter Timer:");
      if (value > -1) {
        relayStates[relay] = 1;
        timer[relay] = value;
      }
      break;

    case 'C':
      value = getKeypadValue(0, 24, "Enter Heure PH:");
      if (value > -1) {
        Heure_PH[relay] = value;
        value = getKeypadValue(0, 60, "Enter Min PH:");
        if (value > -1) {
          Min_PH[relay] = value;
          timer[relay] = getKeypadValue(1, 999, "Enter Duration:");
        }
      }
      break;

    case 'D':
      exitFlag = true;
      lcd.clear();
      lcd.noBacklight();
      break;
  }
}
}

int getKeypadValue(int minVal, int maxVal, char* infoText) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(infoText);
  lcd.setCursor(0, 1);
  lcd.print("A-VALIDER D-QUITTER");
  
  int value = 0;
  bool exitFlag = false;
  while (!exitFlag) {
    char key = keypad.waitForKey();

    if (key >= '0' && key <= '9') {
      int newVal = value * 10 + (key - '0');
      if (newVal >= minVal && newVal <= maxVal) {
        value = newVal;
        lcd.print(key);
      }
    } else if (key == 'D') {
      return -1; // Annuler l'entrée
    } else if (key == 'A') {
      exitFlag = true;
    }
  }

  return value;
}

void infoMenu() {
  // Gérer l'affichage et l'interaction avec le menu d'informations
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("A-Temp   B-Hum");
  lcd.setCursor(0, 1);
  lcd.print("D-Quit");

  bool quit = false;
  while (!quit) {
    char key = keypad.waitForKey();
    switch (key) {
      case 'A': showTemps(); break;
      case 'B': showHumidity(); break;
      case 'D': quit = true; break;
    }
  }
}

void showTemps() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("T1:");
  lcd.print(temp1, 1);
  lcd.setCursor(0, 1);
  lcd.setCursor(0, 4);
  lcd.print("D-Quit");

char key;
do {
  key = keypad.waitForKey();
} while (key != 'D');
}
void showHumidity() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("H1:");
  lcd.print(hum1, 1);

  lcd.print("D-Quit");

  char key;
  do {
    key = keypad.waitForKey();
  } while (key != 'D');
}