#include <Keypad.h>
#include <LiquidCrystal.h>
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd (rs, en, d4, d5, d6, d7);
const byte ROWS = 3;
const byte COLS = 3;
char hexaKeys[ROWS][COLS] = {
{ 1, 2, 3},
{ 4, 5, 6},
{ 7, 8, 9},
};
byte rowPins[ROWS] = {8, 9, 10};
byte colPins[COLS] = {11, 12, 13};
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
unsigned char customKey;
void setup() {
lcd.begin(16, 2);
}
void loop() {
customKey = customKeypad.getKey();
if (customKey != 0)
{
if (customKey == 1)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("1");
}
if (customKey == 2)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("2");
}
if (customKey == 3)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("3");
}
if (customKey == 1)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("1");
}
if (customKey == 4)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("4");
}
if (customKey == 5)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("5");
}
if (customKey == 6)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("6");
}
if (customKey == 7)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("7");
}
if (customKey == 8)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("8");
}
if (customKey == 9)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("9");
}
}
}