/*Write a program to interface LCD and keypad with Arduino board and display
the key pressed from keypad on LCD.*/
#include <LiquidCrystal.h>
#include <Keypad.h>
LiquidCrystal lcd(0, 1, 2, 3, 4, 5);
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowpin[ROWS] = {13, 12, 11, 10};
byte colpin[COLS] = {9, 8, 7, 6};
Keypad keypad = Keypad(makeKeymap(keys), rowpin, colpin, ROWS, COLS);
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
}
void loop() {
// put your main code here, to run repeatedly:
char key = keypad.getKey();
if (key) {
lcd.setCursor(1, 0);
lcd.print("Your key :");
lcd.print(key);
}
}