#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
const byte ROWS = 1;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1', '2', '3', '4'}
};
byte rowPins[ROWS] = {8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 6, 3, 2}; //connect to the column pinouts of the keypad
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.setCursor(1,0);
lcd.print("Hello, world!");
lcd.setCursor(0,1);
lcd.print("Ywrobot Arduino!");
Serial.begin(9600);
}
void loop()
{
static char key = keypad.getKey();
if (key){
Serial.println(key);
}
}