#include <Keypad.h>
#include <LiquidCrystal.h>
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] = {2,3,4,5}; //connect to the row pinouts of the keypad
byte colPins[cols] = {6,7,8,9}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
String intendedKeyCode = "";
int num = 0;
char key;
//----------------KEYPAD----------------//
LiquidCrystal lcd(A0,A1,10,11,12,13);
//------------------LCD-----------------//
void setup() {
Serial.begin(9600);
lcd.begin(20,4);
lcd.setCursor(0,0);
lcd.write("Welcome to dd's GUI");
}
void checkForCredentials()
{
if(intendedKeyCode == "2007")
{
num = 0;
intendedKeyCode = "";
return;
}
else{
num = 0;
intendedKeyCode = "";
return;
}
}
void loop() {
key = keypad.getKey();
if(key != NO_KEY)
{
if(num == 4)
{
checkForCredentials();
return;
}
intendedKeyCode = intendedKeyCode + String(key);
num++;
Serial.println(num);
Serial.println(intendedKeyCode);
}
}