#include <LiquidCrystal_I2C.h>
#include"keypad.h"
#include <Servo.h>
LiquidCrystal_I2C lcd(0x27,16,2);
keypad key;
Servo servo;
void setup() {
lcd.init();
lcd.backlight();
servo.attach(11);
key.ColPins(3,2,8,9);
key.RowPins(7,6,5,4);
key.AvoidKeys("BCD");
key.clearKey("A");
}
String d;
bool l;
void loop(){
lcd.setCursor(0,0);
lcd.print(l==0?"Enter your pass":"press # to lock");
lcd.setCursor(0,1);
lcd.print(key.Getstring());
if(d!=key.Getstring()){
d=key.Getstring();
lcd.clear();
}
if(d.length()>3){
lcd.setCursor(0,1);
if(d=="1593"){
lcd.print("Unlocked");
delay(2000);
l=1;
}
else{
l=0;
lcd.print("Wrong password");
delay(1000);
lcd.clear();
lcd.print("locking.. ");
delay(1000);
}
key.clearStr();
}
if(d=="#"){
l=0;
key.clearStr();
lcd.print("locking....");
delay(1000);
}
servo.write(l==0?90:0);
//if(key.Getstring()!=)
}