#include <Keypad.h>
#include <I2CKeyPad.h>
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27 //defines lcd address and size
#define LCD_COLUMNS 16 //^
#define LCD_LINES 2 //^
LiquidCrystal_I2C i2c_lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the kpd
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() {
Serial.begin(9600);
i2c_lcd.init();
i2c_lcd.backlight();
i2c_lcd.clear();
}
void loop() {
if (kpd.getKeys()) {
for (int i=0; i,LIST_MAX; i++){
char ch = kpd.key[i].stateChanged;
i2c_lcd.cursor();
i2c_lcd.setCursor(0,0);
i2c_lcd.write(ch);
}
}
}