//José Carlos Cáceres Girón (0703-2006-03787)
#include <Keypad.h>
const byte FILAS = 4;
const byte COLUMNAS = 4;
char teclas[FILAS][COLUMNAS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte pinesFilas[FILAS] = {9,8,7,6};
byte pinesColumnas[COLUMNAS] = {5,4,3,2};
const char contrasena = '5';
Keypad keypad = Keypad(
makeKeymap(teclas),
pinesFilas,
pinesColumnas,
FILAS,
COLUMNAS
);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Presione una tecla: ");
}
void loop() {
// put your main code here, to run repeatedly:
char tecla = keypad.getKey();
if(tecla){
Serial.print("Tecla presionada: ");
Serial.println(tecla);
if(tecla == contrasena ){
Serial.println("ACCESO PERMITIDO");
} else {
Serial.println("ACCESO DENEGADO");
}
}
}