#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Keypad.h>
LiquidCrystal_I2C lcd(0x27,16,2);
const byte filas = 4;
const byte columnas = 4;
String suma = "";
byte pinesfilas[] = {16,17,18,19};
byte pinescolumnas[] = {6,7,8,9};
char teclas [4][4]= {{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}};
int led=13;
Keypad teclado = Keypad (makeKeymap(teclas),pinesfilas,pinescolumnas,filas,columnas);
void setup()
{
lcd.init();
lcd.backlight();
lcd.begin(16, 2);
lcd.print(" TECLA ");
}
void loop()
{
char tecla_presionar = teclado.getKey();
if (tecla_presionar){
if (tecla_presionar == '#'){
suma = "";
tecla_presionar = ' ';
}
suma=suma+tecla_presionar;
lcd.clear();
lcd.setCursor (0,0);
if (tecla_presionar == '1' ){
digitalWrite (led, 1);}
else {
digitalWrite (led,0);}
lcd.print (suma);
delay (50);
}
}