#include <LiquidCrystal.h>
#include <Keypad.h>
#include <Wire.h>
const uint8_t ROWS = 4; //four rows
const uint8_t COLS = 4; //five columns
char Keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {19, 18, 5, 17};
byte colPins[COLS] = {16, 4, 2, 15};
Keypad keypad = Keypad( makeKeymap(Keys), rowPins, colPins, ROWS, COLS);
char pass[6]="12345";
char ingresaPass[6];
int indice=0;
void setup(){
Serial.begin(9600);
}
void loop(){
char key = keypad.getKey();
if (key){
ingresaPass[indice]=key;
indice++;
Serial.println(key);
}
if(indice==5){
if(strcmp(pass,ingresaPass)==0){
Serial.println("Acceso permitido");
}
else{
Serial.println("Acceso denegado");
}
indice=0;
}
}