#include<LiquidCrystal.h>
#include <Keypad.h>
char keys[4][4] = {
{'1','2','3', 'A'},
{'4','5','6', 'B'},
{'7','8','9', 'C'},
{'*','0','#', 'D'}
};
byte pin_rows[4] = {7, 6, 5, 4}; //connect to the row of the keypad
byte pin_column[4] = {3, 2, 8, 9}; //connect to the column of the keypad
Keypad keypad = Keypad( makeKeymap(keys), pin_rows, pin_column, 4, 4 );
LiquidCrystal lcd(21, 20, 19, 18, 17, 16);// rs, en, d4,d5,d6,d7
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop()
{
char key = keypad.getKey();
if (key){
Serial.println(key);
lcd.setCursor(0,0); // column, row
lcd.print(key);
}
}