#include <Keypad.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,10,11,12,13);
const byte numRows= 4;
const byte numCols= 4;
char keymap[numRows][numCols]= {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[numRows] = {7,6,5,4};
byte colPins[numCols]= {3,2,1,0};
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows,
numCols);
byte i=0;
char r[4];
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.begin(16,2);
lcd.print("password:");
}
void loop() {
// put your main code here, to run repeatedly:
char key = myKeypad.getKey();
if (key!=NO_KEY)
{
lcd.print(key);
r[i]=key;
i++;
}
Serial.println(i);
if (i==4){
i=0;
if (r[0]=='0' && r[1]=='0' && r[2]=='1' && r[3]=='1'){
lcd.setCursor(0, 1);
lcd.print("Acsess");
}
else{
lcd.setCursor(0, 1);
lcd.print("denied");
delay(1500);
lcd.clear();
delay(200);
lcd.clear();
lcd.home();
lcd.print("password:");
}
}
}