// Incluir las librerías:
#include <Wire.h> // Libreria para comunicación I2C
#include <LiquidCrystal_I2C.h> // Libreria para LCD
#include <Keypad.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const byte NF = 4; //Numero de filas del teclado
const byte NC = 4; //Numero de columnas del teclado
byte PinesFilas[] = {2,3,4,5};
byte PinesColumnas[] = {11,10,9,8};
char Dis_teclas[4][4] = {{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}};
char Tecla_Pres;
Keypad teclado = Keypad(makeKeymap(Dis_teclas),PinesFilas,PinesColumnas,NF,NC);
void setup()
{
lcd.init();
Serial.begin(9600);
Serial.println("Teclado 4x4");
Serial.println();
}
void loop()
{
Tecla_Pres = teclado.getKey();
if (Tecla_Pres)
{
Serial.print("Tecla: ");
Serial.println(Tecla_Pres);
lcd.setCursor(0,0);
lcd.print("TECLA PRESIONADA");
lcd.setCursor(0,1);
lcd.print(Tecla_Pres);
}
}