Keypad repeating last digit press

Hello guys,

I work in an escape game in paris and i'm working on a fake bombe that i found on internet that maybe was a bit old but well documented (bombe arduino by freeman83)
I was unable to received the shift register 74hc595n chip but i've notice that delivered with my 16x2 Lcd screen, there is a chip called "LCD 2004/LCD1602" wich has the same purpose, so i download the appropriate library and change a bit the code, use the "SCL/SDA" input of the arduino uno and get me screen and microprogram running.
But one issue appear, it seems that after the first phase of the bombe that is "arming it", the last digit keep repeating itself, and when i change the code, the digit that was repeating itself change to the last i pressed on the previous panel.
I'm not enought selftought to find where this issue is, in the code , in the wiring or maybe welding ?

It seems that the usb and buzzer piezzo doesn't work either, i'm completly lost, should i start from another tutorial or is it possible to save it ?

Thank you in advance everyone

youtube upload of the situation : https://youtu.be/mLTPLdx-ut0?si=GoA0to6hmI6QbXny

CODE here :

/*programme bombe airsoft avec compte a rebours
*contacteurs anti-soulevement et anti ouverture
*et prise piratage, activation et desactivation par code.
*programme trouvé sur different sites et modifié par Freeman83
*merci a PIC-PAC du forum krispies et a lorrio du forum openclassroom
*/

// Déclaration de la librairie :
#include <LCDI2C_Multilingual.h>
#include <LiquidCrystal.h>
#include <Keypad.h> // inclusion de la librairie pour clavier matriciel

LCDI2C_Latin lcd(0x27, 16, 2);

/* initialise la librairie en précisant les sorties utilisées
* Les connexions sont les suivantes :
* 74HC595 broche 8 connecté a la masse
* 74HC595 broche 10 connecté au +5v
* 74HC595 broche 11 connecté a la broche 12 de l'arduino R3
* 74HC595 broche 12 connecté a la broche 11 de l'arduino R3
* 74HC595 broche 13 connecté a la masse
* 74HC595 broche 14 connecté a la broche 10 de l'arduino R3
* 74HC595 broche 16 connecté au +5v
* 74HC595 broches 4 et 5 sont deux sorties possibles, broche 9 n'est pas utilisé
* LCD broche RS connectée à la broche    QH/7 du 74HC595
* LCD broche Enable connecté à la broche QG/6 du 74HC595
* LCD broche D4 connectée à la broche    QD/3  du 74HC595
* LCD broche D5 connectée à la broche    QC/2  du 74HC595
* LCD broche D6 connectée à la broche    QB/1  du 74HC595
* LCD broche D7 connectée à la broche    QA/15 du 74HC595
* LCD broche R/W connectée à la masse
* LCD broche D0, D1, D2, D3 connecté à la masse
* Potentiomètre 10K :une broche à +5V l’autre à la masse
* celle du milieu Ă  la broche LCD VO
* clavier broche C4 connectée a la broche 2
* clavier broche C3 connectée a la broche 3
* clavier broche C2 connectée a la broche 4
* clavier broche C1 connectée a la broche 5
* clavier broche L4 connectée a la broche A2
* clavier broche L3 connectée a la broche A3
* clavier broche L2 connectée a la broche A4
* clavier broche L1 connectée a la broche A5
*contacteur couvercle connecté a la broche 6 de l'arduino R3
*contacteur déplacement connecté a la broche 7 de l'arduino R3
*clé USB connecté a la broche 8 de l'arduino R3
*buzzer connecté a la broche 13 de l'arduino R3
*/


//--- Constantes utilisées avec le clavier 4x4
const byte LIGNES = 4; // 4 lignes
const byte COLONNES = 4; //4 colonnes

//--- Définition des touches
char touches[LIGNES][COLONNES] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

int contacteur_couvercle = 6;
int contacteur_deplacement = 7;
int cle_usb = 8;
int speakerpin = 13;
int L1 = A5;
int L2 = A4;
int L3 = A3;
int L4 = A2;
int C1 = 5;
int C2 = 4;
int C3 = 3;
int C4 = 2;

// tableaux de lignes et colonnes
byte BrochesLignes[LIGNES] = {L1, L2, L3, L4}; //connexions utilisées pour les broches de lignes du clavier
byte BrochesColonnes[COLONNES] = {C1, C2, C3, C4}; //connexions utilisées pour les broches de colonnes du clavier


Keypad keypad = Keypad( makeKeymap(touches), BrochesLignes, BrochesColonnes, LIGNES, COLONNES );

//Defini tous les etats de la bombe
#define READY 0
#define ARMED 1
#define DISARMED 2
#define DETONATED 3
#define speakerPin 13
int etat1; //etat du contacteur couvercle
int etat2; //etat du contacteur deplacement
int etat3; //etat de la cle usb
int second=0, minute=10, hour=0; // declare time variables
int bombState=0; //0 = Ready, 1 = Armed, 2 = Disarmed, 3 = detonated
int repeat=0;//flag to prevent repeat of getArmCode();
int repeatAdm=0; //flag to prevent repeat of getAadminCode();
int repeatDisarm=0;//flag to prevent repeat of getDisarmCode();
int repeatBuzzer=0;//flag to prevent buzzer from running multiple times.
int repeatTimerEdit=0;//flag to prevent repeat of timer edit function
int blinkArmed = 0;  // flag for blink text
int blinkDisarmed = 0;  // flag to blink disarmed msg
int nbBlinkDisarmed = 6;  // flag for number of blink disarmed msg (real number of blink = nbBlinkDisarmed / 2)
long previousTime = 0;//holds previous time in ms
long previousDelay = 0;//holds previous time in ms since buzzer was active
long interval = 60000;//60 second delay

char hour_str[4]; // For Convert int in char
char minute_str[4]; // For Convert int in char
char second_str[4]; // For Convert int in char
char timeInt_str[0];  // For Convert int in char
char newcode_str[0];
char newarmcode_str[0];
char newdisarmcode_str[0];


char ArmCode[] = "111111";//code pour armer la bombe
char disarmCode[] = "111111";//code pour desarmer la bombe
char adminCode[] = "AD1111";//code administrateur pour entrer dans le menu

char ENTER_KEY = '#';
char CANCEL_KEY = '*';//stores the cancel key variable.
char timeSetKey = '*';//touche a presser pour entrer le code.



void setup()
{
  lcd.init(); lcd.backlight();
  lcd.println("BOMBE BY LUIGI", 3); // wait for 3 seconds before next screen
  delay(2000); lcd.clear();
  lcd.println("Ça température =25±3°C");
}





void loop()

{
   

 switch (bombState) {
lcd.clear();
               
    /***********************************************************
     *Ready state prepares bomb, waits for arm code to be input
     *
     ************************************************************/
  case READY:
    int resultOfGetArmCode;
    lcd.clear();
    lcd.setCursor(0, 0 );
    delay(100);
    //showCursor();
    //blinkCursor();

    lcd.print("Enter ArmCode :"); //Notification du statut.
    digitalWrite(speakerPin, HIGH);
    resultOfGetArmCode = getArmCode();

    if (resultOfGetArmCode == 1) {
      lcd.clear();
      lcd.setCursor(0, 0 );
      delay(100);
      lcd.print("Correct");
      delay(500);
      lcd.clear();
      bombState = ARMED; //debut du compte a rebours

    }//Close getArmCode(); = true

    if (resultOfGetArmCode == 0) {  //si le code est faux, l'ecran affiche "incorrect"
      tryAgainMsg();        

   }// Close getArmCode(); = false.

    break;

    /**************************************************
     *Armed state. Countdown starts, waits for pushbutton to be pressed.
     *If button is pressed, wait for code from keypad.
     ***************************************************/

  case ARMED:
    {  
      char disarmKey = keypad.getKey();
     
     
    etat1 = digitalRead(contacteur_couvercle);
    etat2 = digitalRead(contacteur_deplacement);
    etat3 = digitalRead(cle_usb);
     
   
       if (etat3 == LOW) { //si la cle usb est inseré les contacteurs couvercle et deplacement sont consideré comme appuyé
       etat1 = LOW;
       etat2 = LOW;
      }  
         
        if (etat1 == HIGH)
        bombState = DETONATED; //si le contacteur couvercle est relaché la bombe explose
       

       if (etat2 == HIGH)
       bombState = DETONATED; //si le contacteur de deplacement est relaché la bombe explose
         

      if (disarmKey == '#') {
       char reslutOfDisarm;
        lcd.clear();    
        lcd.setCursor(0, 0 );

        delay(100);
        lcd.print("Enter DisarmCode"); //si la touche de desarmement # est pressée, l'utilisateur peux entrer le code.
        reslutOfDisarm = getDisarmCode();

        if (reslutOfDisarm == true) {  
          lcd.clear();
          bombState = DISARMED; //la bombe passe a l'etat desarmé.
          break;
        } //close getDisarmCode(); = True


        if (reslutOfDisarm == false) {
          tryAgainMsg();

          if (second >= 15) {
            second = second - 15;
          }

         else {
            if (minute == 0 && hour == 0) {
              second=1; //detonate.
            }
            if (minute > 0) {
              second = 60 - (15 - second);
              minute = minute - 1;
           }

            if (hour > 0 && minute == 0) {
              second = 60 - (15 - second);
              minute = 59;
              hour = hour - 1 ;
            }
          }    
        } //close getDisarmCode(); = false  
     } //close if

    }
    countdown(); //si la touche de desarmement # n'est pas pressée, continue le compte a rebours.

    break;

    /**************************************************************
     *DISARMED. Counter stopped, displays "bomb disarmed"
     *
     **************************************************************/

  case DISARMED:
    int blinkDisarmFlag;
    blinkDisarmFlag = 0;
   
    //hideCursor();

    for (nbBlinkDisarmed; nbBlinkDisarmed > 0; nbBlinkDisarmed--){  // blink msg
      if (blinkDisarmFlag == 1){  
        lcd.setCursor(1, 0 );
        lcd.print("BOMBE DESARMEE"); //indique le statut bombe desarmée.
        lcd.setCursor(1, 1 );
        lcd.print("GOOD JOB TEAM");
        delay(5000);
        lcd.clear();
        lcd.setCursor(1, 0 );
        lcd.print("GOOD JOB TEAM"); //bomb has been disarmed, inform user.
        lcd.setCursor(1, 1 );
        lcd.print("BOMBE DESARMEE");
        delay(5000);
     

  asm volatile ("  jmp 0");
       blinkDisarmFlag = 0;
       
      }
      else{
        lcd.clear();
        delay(1000);        
        blinkDisarmFlag = 1;
      }  
    } // end blink
    break;

    /*******************************************************
     *Detonated. activate buzzer for 8 beeps, then 1 long.
     *Print "Have A Nice Day. to LCD.
     ********************************************************/

  case DETONATED:
    if (repeatBuzzer == 0) { //make sure buzzer for loop has not already been run.

      digitalWrite(speakerpin, LOW);//declencher le buzzer
      lcd.clear();
      lcd.setCursor(3, 0 );
      lcd.print("EXPLOSION"); //loop message informing user of bomb detonation.
      //lcd.setCursor(0, 1 );
      //lcd.print("Have A Nice Day"); //loop message informing user of bomb detonation.
      delay(5000);//attendre 5 secondes
      digitalWrite(speakerpin, HIGH);//arreter le buzzer
      repeatBuzzer = 1;//set flag to prevent code from looping again.
    }

    else {
      //lcd.setCursor(0, 0 );
      //lcd.print("EXPLOSION"); //loop message informing user of bomb detonation.
      lcd.setCursor(1, 1 );
      lcd.print("Have A Nice Day"); //loop message informing user of bomb detonation.
      delay(9000);
     

  asm volatile ("  jmp 0");

   }

  }//closes switch
}//closes loop
/*void software_Reset()
{
}*/
/***********************************************************
 * Main countdown timer                                     *
 *                 countdown()                              *
 ************************************************************/
void countdown(){

 static unsigned long lastTick = 0; // set up a local variable to hold the last time we decremented one second
  static unsigned long currentMillis = 0;
  // (static variables are initialized once and keep their values between function calls)

  // decrement one second every 1000 milliseconds
  if (second > 0) {
    if (millis() - lastTick >= 1000) {
      lastTick = millis();
      second--;
      serialOutput();
    }
  }

  // decrement one minute every 60 seconds
  if (minute > 0) {
    if (second <= 0) {
      minute--;
      second = 60; // reset seconds to 60

    }
  }

  // decrement one hour every 60 minutes
  if (hour > 0) {
    if (minute <= 0) {
      hour--;
      minute = 60; // reset minutes to 60
    }//closes if
  }//closes if


  //the code below beeps the siren once every minute.
  currentMillis = millis();
  if (currentMillis - previousTime > interval)
  {
    previousTime = currentMillis;
    previousDelay = currentMillis;

    digitalWrite(speakerPin, LOW);//turn on buzzer
  }

  if (currentMillis - previousDelay > 100) {//100ms chirp duration
    digitalWrite(speakerPin, HIGH);//turn off buzzer
  }
} //close countdown();


/***********************************************************************
 *                          getArmCode();                               *
 *  Grabs the code to arm the bomb from the keypad.                     *
 *                                                                      *
 ************************************************************************/
boolean getArmCode(){
  // returns true when all PW keys are pressed in sequence
  // returns false when number of keys in pW pressed but don't exactly match the PW
  // CANCEL_KEY erases all previous digits input
  int count=0;  // how many keys we have
  int matchCount=0;  // how many keys match
  lcd.setCursor(0, 1 );

  if(repeat == 0){

    for(count=0, matchCount=0; count < sizeof(ArmCode)-1; count++){
      char key;
      char key_str[0];  // Define as string

      do{
        key = keypad.getKey();
        delay (100);
      }
      while(key == '\0');

      key_str[0] = key;
      lcd.print(key_str);

      if (key == timeSetKey && repeatTimerEdit == 0){
// ***************** MOD HERE *********************   ============> Random codes for arm & disarm    
       timerSet();
        return 2;
     }      

     if(key == ArmCode[count]) {
        matchCount++;
      }

      else if(key == CANCEL_KEY){
        count=0;
        matchCount=0;
        return 0;
      }
    }//close for loop
 }//close repeat flag check

  // here when the same number of keys pressed as characters in the PW
  if(matchCount == count) {
    repeat=1;
    return 1;
  }

  else {
    return 0;
  }
}//close getArmCode();


/**********************************************************************
 *                   getDisarmCode();                                  *
 *    Gets disarm code from keypad.                                    *
 *                                                                     *
 ***********************************************************************/
boolean getDisarmCode(){

  // returns true when all PW keys are pressed in sequence
  // returns false when number of keys in pW pressed but don't exactly match the PW
  // CANCEL_KEY erases all previous digits input

  int count=0;  // how many keys we have
  int matchCount=0;  // how many keys match
  long disarmTime = millis()+9000L;//7000 instead of 15000 b/c of added delays making total 30s

  lcd.setCursor(0, 1 );
  //showCursor();
  //blinkCursor();

  if(repeatDisarm == 0){

    for(count=0, matchCount=0; count < sizeof(disarmCode)-1; count++){
      char key;
      char key_str[0];  // Define as string

      do{
        if(disarmTime < millis()){ //if 15 seconds have passed, bail out
          break;
        }

        key = keypad.getKey();
       delay (100);      
     }
      while(key == '\0');

      key_str[0] = key;
      lcd.print(key_str);

      if(key == disarmCode[count]) {
        matchCount++;
      }

      else if(key == CANCEL_KEY){
        count=0;
        matchCount=0;
        return false;
      }

      if(disarmTime < millis()) {
        return false;
        break;
     }

    }// close for loop
  } //close repeat flag check

    // here when the same number of keys pressed as characters in the PW
  if(matchCount == count) {
    repeatDisarm=1;
    return true;
  }
  else {
    return false;

  }
}//close getDisarmCode();


/**********************************************************************
 *                   getAdminCode();                                  *
 *    Gets admin code from keypad.                                    *
 *                                                                     *
 ***********************************************************************/
boolean getAdminCode(){

  // returns true when all PW keys are pressed in sequence
  // returns false when number of keys in pW pressed but don't exactly match the PW
  // CANCEL_KEY erases all previous digits input

  int count=0;  // how many keys we have
  int matchCount=0;  // how many keys match

  lcd.setCursor(0, 1 );


  for(count=0, matchCount=0; count < sizeof(adminCode)-1; count++){
    char key;
    char key_str[0];  // Define as string

    do{
      key = keypad.getKey();
      delay (100);
    }
    while(key == '\0');

//    itoa(key, key_str,10);
    key_str[0] = key;
    lcd.print(key_str);
  //  lcd.print(itoa(key, key_str,16));


    if(key == adminCode[count]) {
      matchCount++;
    }

    else if(key == CANCEL_KEY){
      count=0;
      matchCount=0;
      return false;
    }

  }// close for loop

  // here when the same number of keys pressed as characters in the PW
  if(matchCount == count) {
    return true;
  }
  else{
    return false;
  }
  // Do nothing if pwd is false / Parent function send tryAgin msg
}//close getAdminCode();


/*********************************************************************
 *                        Timer edit function                         *
 *                                                                    *
 *                                                                    *
 **********************************************************************/
void timerSet(){
  lcd.clear();
  lcd.print("Enter AdminCode");
  char resultOfGetAdmCode;

  resultOfGetAdmCode = getAdminCode();

  if (resultOfGetAdmCode == true){
    char timeInt;
    char newcode;
    char newarmcode;
    char newdisarmcode;
    char menupage;
    int newadmincode;
    lcd.clear();  
    lcd.setCursor(0, 0 );
    lcd.print("1.Admin 2.Time");
    lcd.setCursor(0, 1 );
    lcd.print("3.Arm 4.Disarm");
    do{
      menupage = keypad.getKey();
    }
    while(menupage == '\0' || menupage == '*' || menupage == '0' || menupage > 52);
   
    switch(menupage) {
      case '1': // Edit admin code
        lcd.clear();
        lcd.setCursor(0, 0 );
        lcd.print("new admin code :");
        lcd.setCursor(0, 1 );
        do{
           newcode = keypad.getKey();
           delay (100);
        }
       while(newcode == '\0');
       newcode_str[0] = newcode;
       lcd.print(newcode_str);
       adminCode[0] = newcode_str[0];
       newadmincode = (newcode - '0') * 10;//get first digit and convert to int
       do{
       newcode = keypad.getKey();
       delay (100);
        }
        while(newcode == '\0');
        newcode_str[0] = newcode;
        lcd.print(newcode_str);
        adminCode[1] = newcode_str[0];
        newadmincode = (newcode - '0') + newadmincode;//get second digit.
        do{
       newcode = keypad.getKey();
       delay (100);
        }
        while(newcode == '\0');
        newcode_str[0] = newcode;
        lcd.print(newcode_str);
        adminCode[2] = newcode_str[0];
        newadmincode = (newcode - '0') + newadmincode;//get 3rd digit.
        do{
       newcode = keypad.getKey();
       delay (100);
        }
        while(newcode == '\0');
        newcode_str[0] = newcode;
        lcd.print(newcode_str);
        adminCode[3] = newcode_str[0];
        newadmincode = (newcode - '0') + newadmincode;//get 4th digit.
        do{
       newcode = keypad.getKey();
       delay (100);
        }
        while(newcode == '\0');
        newcode_str[0] = newcode;
        lcd.print(newcode_str);
        adminCode[4] = newcode_str[0];
        newadmincode = (newcode - '0') + newadmincode;//get 5th digit.
        do{
       newcode = keypad.getKey();
       delay (100);
        }
        while(newcode == '\0');
        newcode_str[0] = newcode;
        lcd.print(newcode_str);
        adminCode[5] = newcode_str[0];
        newadmincode = (newcode - '0') + newadmincode;//get 6th digit.
     
         //newcode = 'L';
 
       
         lcd.clear();
         
          lcd.setCursor(0, 0 );
          lcd.print("NEW ADMINCODE");
          lcd.setCursor(0, 1 );
          lcd.print(adminCode);
          delay(5000);
          lcd.clear();
       
        break;
       
        case '3': // Edit armcode
        lcd.clear();
        lcd.setCursor(0, 0 );
        lcd.print("new armcode :");
        lcd.setCursor(0, 1 );
        do{
           newarmcode = keypad.getKey();
           delay (100);
        }
       while(newarmcode == '\0');
       newarmcode_str[0] = newarmcode;
       lcd.print(newarmcode_str);
       ArmCode[0] = newarmcode_str[0];
       newarmcode = (newarmcode - '0') * 10;//get first digit and convert to int
       do{
       newarmcode = keypad.getKey();
       delay (100);
        }
        while(newarmcode == '\0');
        newarmcode_str[0] = newarmcode;
        lcd.print(newarmcode_str);
        ArmCode[1] = newarmcode_str[0];
        newarmcode = (newarmcode - '0') + newarmcode;//get second digit.
        do{
       newarmcode = keypad.getKey();delay (100);
        }
        while(newarmcode == '\0');
        newarmcode_str[0] = newarmcode;
        lcd.print(newarmcode_str);
        ArmCode[2] = newarmcode_str[0];
        newarmcode = (newarmcode - '0') + newarmcode;//get 3rd digit.
        do{
       newarmcode = keypad.getKey();
       delay (100);
        }
        while(newarmcode == '\0');
        newarmcode_str[0] = newarmcode;
        lcd.print(newarmcode_str);
        ArmCode[3] = newarmcode_str[0];
        newarmcode = (newarmcode - '0') + newarmcode;//get 4th digit.
        do{
       newarmcode = keypad.getKey();
       delay (100);
        }
        while(newarmcode == '\0');
        newarmcode_str[0] = newarmcode;
        lcd.print(newarmcode_str);
        ArmCode[4] = newarmcode_str[0];
        newarmcode = (newarmcode - '0') + newarmcode;//get 5th digit.
        do{
       newarmcode = keypad.getKey();
       delay (100);
        }
        while(newarmcode == '\0');
        newarmcode_str[0] = newarmcode;
        lcd.print(newarmcode_str);
        ArmCode[5] = newarmcode_str[0];
        newarmcode = (newarmcode - '0') + newarmcode;//get 6th digit.
     
         //newcode = 'L';
 
       
         lcd.clear();
         
          lcd.setCursor(0, 0 );
          lcd.print("NEW ARMCODE");
          lcd.setCursor(0, 1 );
          lcd.print(ArmCode);
          delay(5000);
          lcd.clear();
       
        break;
       
        case '4': // Edit disarmcode
        lcd.clear();
        lcd.setCursor(0, 0 );
        lcd.print("new disarmcode :");
        lcd.setCursor(0, 1 );
        do{
           newdisarmcode = keypad.getKey();
        delay (100);
      }
       while(newdisarmcode == '\0');
       newdisarmcode_str[0] = newdisarmcode;
       lcd.print(newdisarmcode_str);
       disarmCode[0] = newdisarmcode_str[0];
       newdisarmcode = (newdisarmcode - '0') * 10;//get first digit and convert to int
       do{
       newdisarmcode = keypad.getKey();
       delay (100);
        }
        while(newdisarmcode == '\0');
        newdisarmcode_str[0] = newdisarmcode;
        lcd.print(newdisarmcode_str);
        disarmCode[1] = newdisarmcode_str[0];
        newdisarmcode = (newdisarmcode - '0') + newdisarmcode;//get second digit.
        do{
       newdisarmcode = keypad.getKey();
       delay (100);
        }
        while(newdisarmcode == '\0');
        newdisarmcode_str[0] = newdisarmcode;
        lcd.print(newdisarmcode_str);
        disarmCode[2] = newdisarmcode_str[0];
        newdisarmcode = (newdisarmcode - '0') + newdisarmcode;//get 3rd digit.
        do{
       newdisarmcode = keypad.getKey();
       delay (100);
        }
        while(newdisarmcode == '\0');
        newdisarmcode_str[0] = newdisarmcode;
        lcd.print(newdisarmcode_str);
        disarmCode[3] = newdisarmcode_str[0];
        newdisarmcode = (newdisarmcode - '0') + newdisarmcode;//get 4th digit.
        do{
       newdisarmcode = keypad.getKey();
       delay (100);
        }
        while(newdisarmcode == '\0');
        newdisarmcode_str[0] = newdisarmcode;
        lcd.print(newdisarmcode_str);
        disarmCode[4] = newdisarmcode_str[0];
        newdisarmcode = (newdisarmcode - '0') + newdisarmcode;//get 5th digit.
        do{
       newdisarmcode = keypad.getKey();
       delay (100);
        }
        while(newdisarmcode == '\0');
        newdisarmcode_str[0] = newdisarmcode;
        lcd.print(newdisarmcode_str);
        disarmCode[5] = newdisarmcode_str[0];
        newdisarmcode = (newdisarmcode - '0') + newdisarmcode;//get 6th digit.
     
         //newcode = 'L';
 

        lcd.clear();
         
          lcd.setCursor(0, 0 );
          lcd.print("NEW DISARMCODE");
          lcd.setCursor(0, 1 );
          lcd.print(disarmCode);
          delay(5000);
          lcd.clear();
       
        break;
       
      case '2': // Timer
        lcd.clear();
       lcd.print("Enter xx Hours");
        lcd.setCursor(0, 1 );
        do{
           timeInt = keypad.getKey();
        }
        while(timeInt == '\0' || timeInt < '0' || timeInt > '6');
        timeInt_str[0] = timeInt;
        lcd.print(timeInt_str);
 
        hour = (timeInt - '0') * 10;//get first digit and convert to int
        do{
        timeInt = keypad.getKey();
        }
        while(timeInt == '\0');
        timeInt_str[0] = timeInt;
        lcd.print(timeInt_str);
   
        hour = (timeInt - '0') + hour;//get second digit.
        delay(800);
          lcd.clear();
          timeInt = 'L';
          // ------------------------------------------------------------------
          lcd.print("Enter xx Minutes");
          lcd.setCursor(0, 1 );
          do{
            timeInt = keypad.getKey();
          }
          while(timeInt == '\0' || timeInt < '0' || timeInt > '6');
          timeInt_str[0] = timeInt;
          lcd.print(timeInt_str);
     
          while (timeInt < '0' || timeInt > '6'){
            timeInt = keypad.getKey();
          }
          minute = (timeInt - '0') * 10;//get first digit and convert to int
          do{
            timeInt = keypad.getKey();
          }
          while(timeInt == '\0');
          minute = (timeInt - '0') + minute;//get second digit.
          timeInt_str[0] = timeInt;
          lcd.print(timeInt_str);
          delay(800);  
         lcd.clear();
          timeInt = 'L';
          // ------------------------------------------------------------------
          lcd.print("Enter xx Seconds");
          lcd.setCursor(0, 1 );
          do{
            timeInt = keypad.getKey();
          }
          while(timeInt == '\0' || timeInt < '0' || timeInt > '6');
          timeInt_str[0] = timeInt;
          lcd.print(timeInt_str);
     
          while (timeInt < '0' || timeInt > '6'){
            timeInt = keypad.getKey();
          }
          second = (timeInt - '0') * 10;//get first digit and convert to int
          do{
            timeInt = keypad.getKey();
          }
          while(timeInt == '\0');
          second = (timeInt - '0') + second;//get second digit.
          timeInt_str[0] = timeInt;
          lcd.print(timeInt_str);
          delay(800);    
          lcd.clear();
          timeInt = 'L';
          lcd.print("Time set :");
          lcd.setCursor(0, 1 );
          itoa (hour, hour_str, 10);
          itoa (minute, minute_str, 10);
          itoa (second, second_str, 10);
          lcd.print(hour_str);
          lcd.print(":");
          lcd.print(minute_str);
          lcd.print(":");
          lcd.print(second_str);
         delay(2000);  
         // ---------------------- Put randomize here --------------------------
          repeatTimerEdit = 1;
        }//end of getAdminCode == true
     
        if(resultOfGetAdmCode == false){
         tryAgainMsg();
         // Do nothing if pwd is false / Parent function send tryAgin msg
       
       }
        lcd.clear();
      }//end of timer edit function
}



/****************************************************************
 *                     serialOutput();                           *
 *    prints the values of the timer over the serial connection  *
 *         and onto the LCD                                      *
 *****************************************************************/
void serialOutput() {

 
  itoa (hour, hour_str, 10);
  itoa (minute, minute_str, 10);
  itoa (second, second_str, 10);
 

  if(bombState != DISARMED){
 
   lcd.setCursor(0, 0 );
    delay(20);
    if (blinkArmed == 0){
      lcd.print("!!   ARMED    !!");
      blinkArmed=1;
    }
    else {
      lcd.print("!!            !!");
      blinkArmed=0;      
    }
    lcd.setCursor(0, 1 );
   
    lcd.print("Time = ");
    if (hour <=9) {
    lcd.print("0");
    lcd.print(hour_str); // the hour, sent to the screen in decimal format
    }
    else{
    lcd.print(hour_str);
   }
    lcd.print(":"); // a colon between the hour and the minute
    if (minute <=9) {
    lcd.print("0");
    lcd.print(minute_str); // the minute, sent to the screen in decimal format
    }
    else{
    lcd.print(minute_str);
    }
    lcd.print(":"); // a colon between the minute and the second
    if (second <=9) {
    lcd.print("0");
    lcd.print(second_str); // the minute, sent to the screen in decimal format
    }
    else{
      lcd.print(second_str);
    }
    //termination condition
  }
  if (second == 0 && minute == 0 && hour == 0) {
    lcd.clear();
   
    bombState = DETONATED; //clear LCD and set bomb state to "detonated" when timer runs out
  }

  if (bombState == DISARMED) {
    lcd.clear();
 }
}//close serialOutput();


void tryAgainMsg(){
  lcd.clear();
  //hideCursor();
  delay(100);        
  lcd.print("T");
  delay(150);
  lcd.print("r");
  delay(150);
  lcd.print("y");
  delay(150);        
  lcd.print(" ");
  delay(150);
  lcd.print("a");
  delay(150);          
 lcd.print("g");
  delay(150);
  lcd.print("a");
  delay(150);          
 lcd.print("i");
  delay(150);
  lcd.print("n");
  delay(150);
  lcd.print(" ");
  delay(150);
  lcd.print("!");
  delay(1000);  
}

void incorrectMsg(){
  lcd.clear();
 
  delay(100);        
  lcd.print("I");
  delay(350);
  lcd.print("n");
  delay(350);
  lcd.print("c");
  delay(350);        
  lcd.print("o");
  delay(350);
  lcd.print("r");
  delay(350);          
 lcd.print("r");
  delay(350);
  lcd.print("e");
  delay(350);          
 lcd.print("c");
  delay(350);
  lcd.print("t");
  delay(1000);  
}
//END of bomb program.

I2C / IIC uses A4 (DATA) and A5 (CLOCK) for your LCD display. Pick two different "L#" and post your new code.

Your code works if you make the changes above.

Files for WOKWI.COM simulator...

sketch.ino tab
// https://forum.arduino.cc/t/keypad-repeating-last-digit-press/1273136/2

/*programme bombe airsoft avec compte a rebours
  contacteurs anti-soulevement et anti ouverture
  et prise piratage, activation et desactivation par code.
  programme trouvé sur different sites et modifié par Freeman83
  merci a PIC-PAC du forum krispies et a lorrio du forum openclassroom
*/

// Déclaration de la librairie :
#include <LCDI2C_Multilingual.h>
#include <LiquidCrystal.h>
#include <Keypad.h> // inclusion de la librairie pour clavier matriciel

LCDI2C_Latin lcd(0x27, 16, 2);

/* initialise la librairie en précisant les sorties utilisées
  Les connexions sont les suivantes :
  74HC595 broche 8 connecté a la masse
  74HC595 broche 10 connecté au +5v
  74HC595 broche 11 connecté a la broche 12 de l'arduino R3
  74HC595 broche 12 connecté a la broche 11 de l'arduino R3
  74HC595 broche 13 connecté a la masse
  74HC595 broche 14 connecté a la broche 10 de l'arduino R3
  74HC595 broche 16 connecté au +5v
  74HC595 broches 4 et 5 sont deux sorties possibles, broche 9 n'est pas utilisé
  LCD broche RS connectée à la broche    QH/7 du 74HC595
  LCD broche Enable connecté à la broche QG/6 du 74HC595
  LCD broche D4 connectée à la broche    QD/3  du 74HC595
  LCD broche D5 connectée à la broche    QC/2  du 74HC595
  LCD broche D6 connectée à la broche    QB/1  du 74HC595
  LCD broche D7 connectée à la broche    QA/15 du 74HC595
  LCD broche R/W connectée à la masse
  LCD broche D0, D1, D2, D3 connecté à la masse
  Potentiomètre 10K :une broche à +5V l’autre à la masse
  celle du milieu Ă  la broche LCD VO
  clavier broche C4 connectée a la broche 2
  clavier broche C3 connectée a la broche 3
  clavier broche C2 connectée a la broche 4
  clavier broche C1 connectée a la broche 5
  clavier broche L4 connectée a la broche A2
  clavier broche L3 connectée a la broche A3
  clavier broche L2 connectée a la broche A4
  clavier broche L1 connectée a la broche A5
  contacteur couvercle connecté a la broche 6 de l'arduino R3
  contacteur déplacement connecté a la broche 7 de l'arduino R3
  clé USB connecté a la broche 8 de l'arduino R3
  buzzer connecté a la broche 13 de l'arduino R3
*/


//--- Constantes utilisées avec le clavier 4x4
const byte LIGNES = 4; // 4 lignes
const byte COLONNES = 4; //4 colonnes

//--- Définition des touches
char touches[LIGNES][COLONNES] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

int contacteur_couvercle = 6;
int contacteur_deplacement = 7;
int cle_usb = 8;
int speakerpin = 13;
int L1 = A1;
int L2 = A2;
int L3 = A3;
int L4 = A0;
int C1 = 5;
int C2 = 4;
int C3 = 3;
int C4 = 2;

// tableaux de lignes et colonnes
byte BrochesLignes[LIGNES] = {L1, L2, L3, L4}; //connexions utilisées pour les broches de lignes du clavier
byte BrochesColonnes[COLONNES] = {C1, C2, C3, C4}; //connexions utilisées pour les broches de colonnes du clavier


Keypad keypad = Keypad( makeKeymap(touches), BrochesLignes, BrochesColonnes, LIGNES, COLONNES );

//Defini tous les etats de la bombe
#define READY 0
#define ARMED 1
#define DISARMED 2
#define DETONATED 3
#define speakerPin 13
int etat1; //etat du contacteur couvercle
int etat2; //etat du contacteur deplacement
int etat3; //etat de la cle usb
int second = 0, minute = 10, hour = 0; // declare time variables
int bombState = 0; //0 = Ready, 1 = Armed, 2 = Disarmed, 3 = detonated
int repeat = 0; //flag to prevent repeat of getArmCode();
int repeatAdm = 0; //flag to prevent repeat of getAadminCode();
int repeatDisarm = 0; //flag to prevent repeat of getDisarmCode();
int repeatBuzzer = 0; //flag to prevent buzzer from running multiple times.
int repeatTimerEdit = 0; //flag to prevent repeat of timer edit function
int blinkArmed = 0;  // flag for blink text
int blinkDisarmed = 0;  // flag to blink disarmed msg
int nbBlinkDisarmed = 6;  // flag for number of blink disarmed msg (real number of blink = nbBlinkDisarmed / 2)
long previousTime = 0;//holds previous time in ms
long previousDelay = 0;//holds previous time in ms since buzzer was active
long interval = 60000;//60 second delay

char hour_str[4]; // For Convert int in char
char minute_str[4]; // For Convert int in char
char second_str[4]; // For Convert int in char
char timeInt_str[0];  // For Convert int in char
char newcode_str[0];
char newarmcode_str[0];
char newdisarmcode_str[0];


char ArmCode[] = "111111";//code pour armer la bombe
char disarmCode[] = "111111";//code pour desarmer la bombe
char adminCode[] = "AD1111";//code administrateur pour entrer dans le menu

char ENTER_KEY = '#';
char CANCEL_KEY = '*';//stores the cancel key variable.
char timeSetKey = '*';//touche a presser pour entrer le code.



void setup()
{
  lcd.init(); lcd.backlight();
  lcd.println("BOMBE BY LUIGI", 3); // wait for 3 seconds before next screen
  delay(2000); lcd.clear();
  lcd.println("Ça température =25±3°C");
}





void loop()

{


  switch (bombState) {
      lcd.clear();

    /***********************************************************
      Ready state prepares bomb, waits for arm code to be input

     ************************************************************/
    case READY:
      int resultOfGetArmCode;
      lcd.clear();
      lcd.setCursor(0, 0 );
      delay(100);
      //showCursor();
      //blinkCursor();

      lcd.print("Enter ArmCode :"); //Notification du statut.
      digitalWrite(speakerPin, HIGH);
      resultOfGetArmCode = getArmCode();

      if (resultOfGetArmCode == 1) {
        lcd.clear();
        lcd.setCursor(0, 0 );
        delay(100);
        lcd.print("Correct");
        delay(500);
        lcd.clear();
        bombState = ARMED; //debut du compte a rebours

      }//Close getArmCode(); = true

      if (resultOfGetArmCode == 0) {  //si le code est faux, l'ecran affiche "incorrect"
        tryAgainMsg();

      }// Close getArmCode(); = false.

      break;

    /**************************************************
      Armed state. Countdown starts, waits for pushbutton to be pressed.
      If button is pressed, wait for code from keypad.
     ***************************************************/

    case ARMED:
      {
        char disarmKey = keypad.getKey();


        etat1 = digitalRead(contacteur_couvercle);
        etat2 = digitalRead(contacteur_deplacement);
        etat3 = digitalRead(cle_usb);


        if (etat3 == LOW) { //si la cle usb est inseré les contacteurs couvercle et deplacement sont consideré comme appuyé
          etat1 = LOW;
          etat2 = LOW;
        }

        if (etat1 == HIGH)
          bombState = DETONATED; //si le contacteur couvercle est relaché la bombe explose


        if (etat2 == HIGH)
          bombState = DETONATED; //si le contacteur de deplacement est relaché la bombe explose


        if (disarmKey == '#') {
          char reslutOfDisarm;
          lcd.clear();
          lcd.setCursor(0, 0 );

          delay(100);
          lcd.print("Enter DisarmCode"); //si la touche de desarmement # est pressée, l'utilisateur peux entrer le code.
          reslutOfDisarm = getDisarmCode();

          if (reslutOfDisarm == true) {
            lcd.clear();
            bombState = DISARMED; //la bombe passe a l'etat desarmé.
            break;
          } //close getDisarmCode(); = True


          if (reslutOfDisarm == false) {
            tryAgainMsg();

            if (second >= 15) {
              second = second - 15;
            }

            else {
              if (minute == 0 && hour == 0) {
                second = 1; //detonate.
              }
              if (minute > 0) {
                second = 60 - (15 - second);
                minute = minute - 1;
              }

              if (hour > 0 && minute == 0) {
                second = 60 - (15 - second);
                minute = 59;
                hour = hour - 1 ;
              }
            }
          } //close getDisarmCode(); = false
        } //close if

      }
      countdown(); //si la touche de desarmement # n'est pas pressée, continue le compte a rebours.

      break;

    /**************************************************************
      DISARMED. Counter stopped, displays "bomb disarmed"

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

    case DISARMED:
      int blinkDisarmFlag;
      blinkDisarmFlag = 0;

      //hideCursor();

      for (nbBlinkDisarmed; nbBlinkDisarmed > 0; nbBlinkDisarmed--) { // blink msg
        if (blinkDisarmFlag == 1) {
          lcd.setCursor(1, 0 );
          lcd.print("BOMBE DESARMEE"); //indique le statut bombe desarmée.
          lcd.setCursor(1, 1 );
          lcd.print("GOOD JOB TEAM");
          delay(5000);
          lcd.clear();
          lcd.setCursor(1, 0 );
          lcd.print("GOOD JOB TEAM"); //bomb has been disarmed, inform user.
          lcd.setCursor(1, 1 );
          lcd.print("BOMBE DESARMEE");
          delay(5000);


          asm volatile ("  jmp 0");
          blinkDisarmFlag = 0;

        }
        else {
          lcd.clear();
          delay(1000);
          blinkDisarmFlag = 1;
        }
      } // end blink
      break;

    /*******************************************************
      Detonated. activate buzzer for 8 beeps, then 1 long.
      Print "Have A Nice Day. to LCD.
     ********************************************************/

    case DETONATED:
      if (repeatBuzzer == 0) { //make sure buzzer for loop has not already been run.

        digitalWrite(speakerpin, LOW);//declencher le buzzer
        lcd.clear();
        lcd.setCursor(3, 0 );
        lcd.print("EXPLOSION"); //loop message informing user of bomb detonation.
        //lcd.setCursor(0, 1 );
        //lcd.print("Have A Nice Day"); //loop message informing user of bomb detonation.
        delay(5000);//attendre 5 secondes
        digitalWrite(speakerpin, HIGH);//arreter le buzzer
        repeatBuzzer = 1;//set flag to prevent code from looping again.
      }

      else {
        //lcd.setCursor(0, 0 );
        //lcd.print("EXPLOSION"); //loop message informing user of bomb detonation.
        lcd.setCursor(1, 1 );
        lcd.print("Have A Nice Day"); //loop message informing user of bomb detonation.
        delay(9000);


        asm volatile ("  jmp 0");

      }

  }//closes switch
}//closes loop
/*void software_Reset()
  {
  }*/
/***********************************************************
   Main countdown timer
                   countdown()
 ************************************************************/
void countdown() {

  static unsigned long lastTick = 0; // set up a local variable to hold the last time we decremented one second
  static unsigned long currentMillis = 0;
  // (static variables are initialized once and keep their values between function calls)

  // decrement one second every 1000 milliseconds
  if (second > 0) {
    if (millis() - lastTick >= 1000) {
      lastTick = millis();
      second--;
      serialOutput();
    }
  }

  // decrement one minute every 60 seconds
  if (minute > 0) {
    if (second <= 0) {
      minute--;
      second = 60; // reset seconds to 60

    }
  }

  // decrement one hour every 60 minutes
  if (hour > 0) {
    if (minute <= 0) {
      hour--;
      minute = 60; // reset minutes to 60
    }//closes if
  }//closes if


  //the code below beeps the siren once every minute.
  currentMillis = millis();
  if (currentMillis - previousTime > interval)
  {
    previousTime = currentMillis;
    previousDelay = currentMillis;

    digitalWrite(speakerPin, LOW);//turn on buzzer
  }

  if (currentMillis - previousDelay > 100) {//100ms chirp duration
    digitalWrite(speakerPin, HIGH);//turn off buzzer
  }
} //close countdown();


/***********************************************************************
                            getArmCode();
    Grabs the code to arm the bomb from the keypad.
 *                                                                      *
 ************************************************************************/
boolean getArmCode() {
  // returns true when all PW keys are pressed in sequence
  // returns false when number of keys in pW pressed but don't exactly match the PW
  // CANCEL_KEY erases all previous digits input
  int count = 0; // how many keys we have
  int matchCount = 0; // how many keys match
  lcd.setCursor(0, 1 );

  if (repeat == 0) {

    for (count = 0, matchCount = 0; count < sizeof(ArmCode) - 1; count++) {
      char key;
      char key_str[0];  // Define as string

      do {
        key = keypad.getKey();
        delay (100);
      }
      while (key == '\0');

      key_str[0] = key;
      lcd.print(key_str);

      if (key == timeSetKey && repeatTimerEdit == 0) {
        // ***************** MOD HERE *********************   ============> Random codes for arm & disarm
        timerSet();
        return 2;
      }

      if (key == ArmCode[count]) {
        matchCount++;
      }

      else if (key == CANCEL_KEY) {
        count = 0;
        matchCount = 0;
        return 0;
      }
    }//close for loop
  }//close repeat flag check

  // here when the same number of keys pressed as characters in the PW
  if (matchCount == count) {
    repeat = 1;
    return 1;
  }

  else {
    return 0;
  }
}//close getArmCode();


/**********************************************************************
                     getDisarmCode();
      Gets disarm code from keypad.
 *                                                                     *
 ***********************************************************************/
boolean getDisarmCode() {

  // returns true when all PW keys are pressed in sequence
  // returns false when number of keys in pW pressed but don't exactly match the PW
  // CANCEL_KEY erases all previous digits input

  int count = 0; // how many keys we have
  int matchCount = 0; // how many keys match
  long disarmTime = millis() + 9000L; //7000 instead of 15000 b/c of added delays making total 30s

  lcd.setCursor(0, 1 );
  //showCursor();
  //blinkCursor();

  if (repeatDisarm == 0) {

    for (count = 0, matchCount = 0; count < sizeof(disarmCode) - 1; count++) {
      char key;
      char key_str[0];  // Define as string

      do {
        if (disarmTime < millis()) { //if 15 seconds have passed, bail out
          break;
        }

        key = keypad.getKey();
        delay (100);
      }
      while (key == '\0');

      key_str[0] = key;
      lcd.print(key_str);

      if (key == disarmCode[count]) {
        matchCount++;
      }

      else if (key == CANCEL_KEY) {
        count = 0;
        matchCount = 0;
        return false;
      }

      if (disarmTime < millis()) {
        return false;
        break;
      }

    }// close for loop
  } //close repeat flag check

  // here when the same number of keys pressed as characters in the PW
  if (matchCount == count) {
    repeatDisarm = 1;
    return true;
  }
  else {
    return false;

  }
}//close getDisarmCode();


/**********************************************************************
                     getAdminCode();
      Gets admin code from keypad.
 *                                                                     *
 ***********************************************************************/
boolean getAdminCode() {

  // returns true when all PW keys are pressed in sequence
  // returns false when number of keys in pW pressed but don't exactly match the PW
  // CANCEL_KEY erases all previous digits input

  int count = 0; // how many keys we have
  int matchCount = 0; // how many keys match

  lcd.setCursor(0, 1 );


  for (count = 0, matchCount = 0; count < sizeof(adminCode) - 1; count++) {
    char key;
    char key_str[0];  // Define as string

    do {
      key = keypad.getKey();
      delay (100);
    }
    while (key == '\0');

    //    itoa(key, key_str,10);
    key_str[0] = key;
    lcd.print(key_str);
    //  lcd.print(itoa(key, key_str,16));


    if (key == adminCode[count]) {
      matchCount++;
    }

    else if (key == CANCEL_KEY) {
      count = 0;
      matchCount = 0;
      return false;
    }

  }// close for loop

  // here when the same number of keys pressed as characters in the PW
  if (matchCount == count) {
    return true;
  }
  else {
    return false;
  }
  // Do nothing if pwd is false / Parent function send tryAgin msg
}//close getAdminCode();


/*********************************************************************
                          Timer edit function
 *                                                                    *
 *                                                                    *
 **********************************************************************/
void timerSet() {
  lcd.clear();
  lcd.print("Enter AdminCode");
  char resultOfGetAdmCode;

  resultOfGetAdmCode = getAdminCode();

  if (resultOfGetAdmCode == true) {
    char timeInt;
    char newcode;
    char newarmcode;
    char newdisarmcode;
    char menupage;
    int newadmincode;
    lcd.clear();
    lcd.setCursor(0, 0 );
    lcd.print("1.Admin 2.Time");
    lcd.setCursor(0, 1 );
    lcd.print("3.Arm 4.Disarm");
    do {
      menupage = keypad.getKey();
    }
    while (menupage == '\0' || menupage == '*' || menupage == '0' || menupage > 52);

    switch (menupage) {
      case '1': // Edit admin code
        lcd.clear();
        lcd.setCursor(0, 0 );
        lcd.print("new admin code :");
        lcd.setCursor(0, 1 );
        do {
          newcode = keypad.getKey();
          delay (100);
        }
        while (newcode == '\0');
        newcode_str[0] = newcode;
        lcd.print(newcode_str);
        adminCode[0] = newcode_str[0];
        newadmincode = (newcode - '0') * 10;//get first digit and convert to int
        do {
          newcode = keypad.getKey();
          delay (100);
        }
        while (newcode == '\0');
        newcode_str[0] = newcode;
        lcd.print(newcode_str);
        adminCode[1] = newcode_str[0];
        newadmincode = (newcode - '0') + newadmincode;//get second digit.
        do {
          newcode = keypad.getKey();
          delay (100);
        }
        while (newcode == '\0');
        newcode_str[0] = newcode;
        lcd.print(newcode_str);
        adminCode[2] = newcode_str[0];
        newadmincode = (newcode - '0') + newadmincode;//get 3rd digit.
        do {
          newcode = keypad.getKey();
          delay (100);
        }
        while (newcode == '\0');
        newcode_str[0] = newcode;
        lcd.print(newcode_str);
        adminCode[3] = newcode_str[0];
        newadmincode = (newcode - '0') + newadmincode;//get 4th digit.
        do {
          newcode = keypad.getKey();
          delay (100);
        }
        while (newcode == '\0');
        newcode_str[0] = newcode;
        lcd.print(newcode_str);
        adminCode[4] = newcode_str[0];
        newadmincode = (newcode - '0') + newadmincode;//get 5th digit.
        do {
          newcode = keypad.getKey();
          delay (100);
        }
        while (newcode == '\0');
        newcode_str[0] = newcode;
        lcd.print(newcode_str);
        adminCode[5] = newcode_str[0];
        newadmincode = (newcode - '0') + newadmincode;//get 6th digit.

        //newcode = 'L';


        lcd.clear();

        lcd.setCursor(0, 0 );
        lcd.print("NEW ADMINCODE");
        lcd.setCursor(0, 1 );
        lcd.print(adminCode);
        delay(5000);
        lcd.clear();

        break;

      case '3': // Edit armcode
        lcd.clear();
        lcd.setCursor(0, 0 );
        lcd.print("new armcode :");
        lcd.setCursor(0, 1 );
        do {
          newarmcode = keypad.getKey();
          delay (100);
        }
        while (newarmcode == '\0');
        newarmcode_str[0] = newarmcode;
        lcd.print(newarmcode_str);
        ArmCode[0] = newarmcode_str[0];
        newarmcode = (newarmcode - '0') * 10;//get first digit and convert to int
        do {
          newarmcode = keypad.getKey();
          delay (100);
        }
        while (newarmcode == '\0');
        newarmcode_str[0] = newarmcode;
        lcd.print(newarmcode_str);
        ArmCode[1] = newarmcode_str[0];
        newarmcode = (newarmcode - '0') + newarmcode;//get second digit.
        do {
          newarmcode = keypad.getKey(); delay (100);
        }
        while (newarmcode == '\0');
        newarmcode_str[0] = newarmcode;
        lcd.print(newarmcode_str);
        ArmCode[2] = newarmcode_str[0];
        newarmcode = (newarmcode - '0') + newarmcode;//get 3rd digit.
        do {
          newarmcode = keypad.getKey();
          delay (100);
        }
        while (newarmcode == '\0');
        newarmcode_str[0] = newarmcode;
        lcd.print(newarmcode_str);
        ArmCode[3] = newarmcode_str[0];
        newarmcode = (newarmcode - '0') + newarmcode;//get 4th digit.
        do {
          newarmcode = keypad.getKey();
          delay (100);
        }
        while (newarmcode == '\0');
        newarmcode_str[0] = newarmcode;
        lcd.print(newarmcode_str);
        ArmCode[4] = newarmcode_str[0];
        newarmcode = (newarmcode - '0') + newarmcode;//get 5th digit.
        do {
          newarmcode = keypad.getKey();
          delay (100);
        }
        while (newarmcode == '\0');
        newarmcode_str[0] = newarmcode;
        lcd.print(newarmcode_str);
        ArmCode[5] = newarmcode_str[0];
        newarmcode = (newarmcode - '0') + newarmcode;//get 6th digit.

        //newcode = 'L';


        lcd.clear();

        lcd.setCursor(0, 0 );
        lcd.print("NEW ARMCODE");
        lcd.setCursor(0, 1 );
        lcd.print(ArmCode);
        delay(5000);
        lcd.clear();

        break;

      case '4': // Edit disarmcode
        lcd.clear();
        lcd.setCursor(0, 0 );
        lcd.print("new disarmcode :");
        lcd.setCursor(0, 1 );
        do {
          newdisarmcode = keypad.getKey();
          delay (100);
        }
        while (newdisarmcode == '\0');
        newdisarmcode_str[0] = newdisarmcode;
        lcd.print(newdisarmcode_str);
        disarmCode[0] = newdisarmcode_str[0];
        newdisarmcode = (newdisarmcode - '0') * 10;//get first digit and convert to int
        do {
          newdisarmcode = keypad.getKey();
          delay (100);
        }
        while (newdisarmcode == '\0');
        newdisarmcode_str[0] = newdisarmcode;
        lcd.print(newdisarmcode_str);
        disarmCode[1] = newdisarmcode_str[0];
        newdisarmcode = (newdisarmcode - '0') + newdisarmcode;//get second digit.
        do {
          newdisarmcode = keypad.getKey();
          delay (100);
        }
        while (newdisarmcode == '\0');
        newdisarmcode_str[0] = newdisarmcode;
        lcd.print(newdisarmcode_str);
        disarmCode[2] = newdisarmcode_str[0];
        newdisarmcode = (newdisarmcode - '0') + newdisarmcode;//get 3rd digit.
        do {
          newdisarmcode = keypad.getKey();
          delay (100);
        }
        while (newdisarmcode == '\0');
        newdisarmcode_str[0] = newdisarmcode;
        lcd.print(newdisarmcode_str);
        disarmCode[3] = newdisarmcode_str[0];
        newdisarmcode = (newdisarmcode - '0') + newdisarmcode;//get 4th digit.
        do {
          newdisarmcode = keypad.getKey();
          delay (100);
        }
        while (newdisarmcode == '\0');
        newdisarmcode_str[0] = newdisarmcode;
        lcd.print(newdisarmcode_str);
        disarmCode[4] = newdisarmcode_str[0];
        newdisarmcode = (newdisarmcode - '0') + newdisarmcode;//get 5th digit.
        do {
          newdisarmcode = keypad.getKey();
          delay (100);
        }
        while (newdisarmcode == '\0');
        newdisarmcode_str[0] = newdisarmcode;
        lcd.print(newdisarmcode_str);
        disarmCode[5] = newdisarmcode_str[0];
        newdisarmcode = (newdisarmcode - '0') + newdisarmcode;//get 6th digit.

        //newcode = 'L';


        lcd.clear();

        lcd.setCursor(0, 0 );
        lcd.print("NEW DISARMCODE");
        lcd.setCursor(0, 1 );
        lcd.print(disarmCode);
        delay(5000);
        lcd.clear();

        break;

      case '2': // Timer
        lcd.clear();
        lcd.print("Enter xx Hours");
        lcd.setCursor(0, 1 );
        do {
          timeInt = keypad.getKey();
        }
        while (timeInt == '\0' || timeInt < '0' || timeInt > '6');
        timeInt_str[0] = timeInt;
        lcd.print(timeInt_str);

        hour = (timeInt - '0') * 10;//get first digit and convert to int
        do {
          timeInt = keypad.getKey();
        }
        while (timeInt == '\0');
        timeInt_str[0] = timeInt;
        lcd.print(timeInt_str);

        hour = (timeInt - '0') + hour;//get second digit.
        delay(800);
        lcd.clear();
        timeInt = 'L';
        // ------------------------------------------------------------------
        lcd.print("Enter xx Minutes");
        lcd.setCursor(0, 1 );
        do {
          timeInt = keypad.getKey();
        }
        while (timeInt == '\0' || timeInt < '0' || timeInt > '6');
        timeInt_str[0] = timeInt;
        lcd.print(timeInt_str);

        while (timeInt < '0' || timeInt > '6') {
          timeInt = keypad.getKey();
        }
        minute = (timeInt - '0') * 10;//get first digit and convert to int
        do {
          timeInt = keypad.getKey();
        }
        while (timeInt == '\0');
        minute = (timeInt - '0') + minute;//get second digit.
        timeInt_str[0] = timeInt;
        lcd.print(timeInt_str);
        delay(800);
        lcd.clear();
        timeInt = 'L';
        // ------------------------------------------------------------------
        lcd.print("Enter xx Seconds");
        lcd.setCursor(0, 1 );
        do {
          timeInt = keypad.getKey();
        }
        while (timeInt == '\0' || timeInt < '0' || timeInt > '6');
        timeInt_str[0] = timeInt;
        lcd.print(timeInt_str);

        while (timeInt < '0' || timeInt > '6') {
          timeInt = keypad.getKey();
        }
        second = (timeInt - '0') * 10;//get first digit and convert to int
        do {
          timeInt = keypad.getKey();
        }
        while (timeInt == '\0');
        second = (timeInt - '0') + second;//get second digit.
        timeInt_str[0] = timeInt;
        lcd.print(timeInt_str);
        delay(800);
        lcd.clear();
        timeInt = 'L';
        lcd.print("Time set :");
        lcd.setCursor(0, 1 );
        itoa (hour, hour_str, 10);
        itoa (minute, minute_str, 10);
        itoa (second, second_str, 10);
        lcd.print(hour_str);
        lcd.print(":");
        lcd.print(minute_str);
        lcd.print(":");
        lcd.print(second_str);
        delay(2000);
        // ---------------------- Put randomize here --------------------------
        repeatTimerEdit = 1;
    }//end of getAdminCode == true

    if (resultOfGetAdmCode == false) {
      tryAgainMsg();
      // Do nothing if pwd is false / Parent function send tryAgin msg

    }
    lcd.clear();
  }//end of timer edit function
}



/****************************************************************
                       serialOutput();
      prints the values of the timer over the serial connection
           and onto the LCD
 *****************************************************************/
void serialOutput() {


  itoa (hour, hour_str, 10);
  itoa (minute, minute_str, 10);
  itoa (second, second_str, 10);


  if (bombState != DISARMED) {

    lcd.setCursor(0, 0 );
    delay(20);
    if (blinkArmed == 0) {
      lcd.print("!!   ARMED    !!");
      blinkArmed = 1;
    }
    else {
      lcd.print("!!            !!");
      blinkArmed = 0;
    }
    lcd.setCursor(0, 1 );

    lcd.print("Time = ");
    if (hour <= 9) {
      lcd.print("0");
      lcd.print(hour_str); // the hour, sent to the screen in decimal format
    }
    else {
      lcd.print(hour_str);
    }
    lcd.print(":"); // a colon between the hour and the minute
    if (minute <= 9) {
      lcd.print("0");
      lcd.print(minute_str); // the minute, sent to the screen in decimal format
    }
    else {
      lcd.print(minute_str);
    }
    lcd.print(":"); // a colon between the minute and the second
    if (second <= 9) {
      lcd.print("0");
      lcd.print(second_str); // the minute, sent to the screen in decimal format
    }
    else {
      lcd.print(second_str);
    }
    //termination condition
  }
  if (second == 0 && minute == 0 && hour == 0) {
    lcd.clear();

    bombState = DETONATED; //clear LCD and set bomb state to "detonated" when timer runs out
  }

  if (bombState == DISARMED) {
    lcd.clear();
  }
}//close serialOutput();


void tryAgainMsg() {
  lcd.clear();
  //hideCursor();
  delay(100);
  lcd.print("T");
  delay(150);
  lcd.print("r");
  delay(150);
  lcd.print("y");
  delay(150);
  lcd.print(" ");
  delay(150);
  lcd.print("a");
  delay(150);
  lcd.print("g");
  delay(150);
  lcd.print("a");
  delay(150);
  lcd.print("i");
  delay(150);
  lcd.print("n");
  delay(150);
  lcd.print(" ");
  delay(150);
  lcd.print("!");
  delay(1000);
}

void incorrectMsg() {
  lcd.clear();

  delay(100);
  lcd.print("I");
  delay(350);
  lcd.print("n");
  delay(350);
  lcd.print("c");
  delay(350);
  lcd.print("o");
  delay(350);
  lcd.print("r");
  delay(350);
  lcd.print("r");
  delay(350);
  lcd.print("e");
  delay(350);
  lcd.print("c");
  delay(350);
  lcd.print("t");
  delay(1000);
}
//END of bomb program.
diagram.json tab
{
  "version": 1,
  "author": "Anonymous maker",
  "editor": "wokwi",
  "parts": [
    { "type": "wokwi-arduino-nano", "id": "nano", "top": 0, "left": 0, "attrs": {} },
    {
      "type": "wokwi-lcd1602",
      "id": "lcd1",
      "top": 169.6,
      "left": 178.4,
      "attrs": { "pins": "i2c" }
    },
    { "type": "wokwi-membrane-keypad", "id": "keypad1", "top": -290, "left": -215.2, "attrs": {} }
  ],
  "connections": [
    [ "nano:GND.1", "lcd1:GND", "black", [ "v0" ] ],
    [ "nano:5V", "lcd1:VCC", "red", [ "v0" ] ],
    [ "lcd1:SDA", "nano:A4", "green", [ "h0" ] ],
    [ "nano:A5", "lcd1:SCL", "green", [ "v0" ] ],
    [ "keypad1:R1", "nano:A1", "green", [ "v28.8", "h163.2" ] ],
    [ "keypad1:R2", "nano:A2", "green", [ "v38.4", "h143.6" ] ],
    [ "keypad1:R3", "nano:A3", "green", [ "v48", "h172.5" ] ],
    [ "keypad1:R4", "nano:A0", "green", [ "v57.6", "h105.4" ] ],
    [ "keypad1:C1", "nano:5", "green", [ "v86.4", "h278.3", "v-192", "h-114.7" ] ],
    [ "keypad1:C2", "nano:4", "green", [ "v96", "h259.2", "v-192", "h-95.5" ] ],
    [ "keypad1:C3", "nano:3", "green", [ "v105.6", "h239.85", "v-192", "h-76.3" ] ],
    [ "keypad1:C4", "nano:2", "green", [ "v115.2", "h220.5", "v-192", "h-57.1" ] ]
  ],
  "dependencies": {}
}

*** be sure to add library file: LiquidCrystal I2C Multilingual