#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcdabed(0x27,16,2);
const byte rows = 4; //four rows
const byte cols = 4; //three columns
char keys[rows][cols] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
byte rowPins[rows] = {9,8,7,6}; //connect to the row pinouts of the keypad
byte colPins[cols] = {5,4,3,2}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );

char key;
String KeyCode = "";
String myCode = "1234#";
int num = 0;

void setup() {
  lcdabed.init();
  lcdabed.backlight(); 
  lcdabed.clear();

  lcdabed.setCursor(3,0);
  lcdabed.println("please Enter");
  lcdabed.setCursor(5,1);
  lcdabed.print("code....");
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);

  

}

void loop() {

 key = keypad.getKey();
  if(key)
  {  
    lcdabed.clear();
    lcdabed.setCursor(5,0);
    lcdabed.print("****");
     num++;
     KeyCode = KeyCode + String(key);
  }
     if(num==5)
          {    
            
             if(KeyCode==myCode)
             
            { 
               lcdabed.clear();
               lcdabed.setCursor(0,0);
               lcdabed.print("password is ok");
               num=0;
               digitalWrite(11,1);
               delay(1000);
               digitalWrite(11,0);

               KeyCode="";
           }
           else
           {
            lcdabed.clear();
            lcdabed.setCursor(0,0);
            lcdabed.print("please try again");
            digitalWrite(10,1);
            delay(1000);
            digitalWrite(10,0);
            KeyCode="";
            num=0;

           }
          
      }


}