#include <Wire.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
#define ROW_NUM 4 // define numero de filas
#define COLUMN_NUM 4 // define numero de columnas
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','4','7','*'},
{'2','5','8','0'},
{'3','8','9','#'},
{'A','B','C','D'}
};
byte pin_rows[ROW_NUM] = {17, 5, 18, 19}; //{19, 18, 5, 17} pines correspondientes a las filas GIOP19, GIOP18, GIOP5, GIOP17
byte pin_column[COLUMN_NUM] = {15, 2, 4, 16}; //{16, 0, 2, 15} pines correspondientes a las columnas GIOP16, GIOP4, GIOP0, GIOP2
//{16, 4, 2, 15} pines correspondientes a las columnas GIOP16, GIOP4, GIOP2, GIOP15
Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM );
LiquidCrystal_I2C lcd(0x27, 20, 4); // I2C address 0x27, 16 column and 2 rows
int cursorColumn = 0;
void setup(){
lcd.init(); // initialize the lcd
lcd.backlight();
}
void loop(){
char key = keypad.getKey();
if (key) {
lcd.setCursor(cursorColumn, 0); // move cursor to (cursorColumn, 0)
lcd.print(key); // print key at (cursorColumn, 0)
cursorColumn++; // move cursor to next position
if(cursorColumn == 21) { // if reaching limit, clear LCD
lcd.clear();
cursorColumn = 0;
}
}
}