#include <Keypad.h>
const int rowmo=4;
const int colno=4;
char keys[rowmo][colno]={{'1','2','3','A'},{'4','5','6','B'},{'7','8','9','C'},{'*','0','#','D'}};
byte rowpin[rowmo]={9,8,7,6};
byte colpin[colno]={5,4,3,2};
Keypad keypad1=Keypad(makeKeymap(keys),rowpin,colpin,rowmo,colno);
const String password="2003";
String input_password="";
#define led 10
void setup()
{
Serial.begin(9600);
pinMode(led,OUTPUT);
input_password.reserve(100);
// put your setup code here, to run once:
}
void loop()
{
char key=keypad1.getKey();
digitalWrite(led,1);
if(key!=NO_KEY)
{
if(key=='0'||key=='1'||key=='2'||key=='3'||key=='4'||key=='5'||key=='6'||key=='7'||
key=='8'||key=='9')
{
input_password+=key;
}
else input_password="";
if(password==input_password)
{
Serial.println("correct password");
digitalWrite(led,0);
delay(10000);
input_password="";
}
else
digitalWrite(led,1);
}
/*char key=keypad1.getKey();
//if(key!=NO_KEY)
{
Serial.println(key);
}*/
// put your main code here, to run repeatedly:
}