#include #include LiquidCrystal_I2C lcd(0x27, 20, 4); const int a = 23; const int b = 25; const int c = 27; const int d = 29; const int e = 31; const int f = 33; const int g = 35; const int p = 37; const int Rows = 4; const int Cols = 4; char keys [Rows][Cols] = { {'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'} }; byte rowPins [Rows] = {1,2,3,4}; byte colPins [Cols] = {5,6,7,8}; Keypad keypad = Keypad (makeKeymap(keys), rowPins, colPins, Rows, Cols); void setup() { lcd.init(); lcd.backlight(); lcd.clear(); lcd.setCursor(0, 0); pinMode(p, OUTPUT); pinMode(a, OUTPUT); pinMode(a, OUTPUT); pinMode(b, OUTPUT); pinMode(c, OUTPUT); pinMode(d, OUTPUT); pinMode(e, OUTPUT); pinMode(f, OUTPUT); pinMode(g, OUTPUT); } void keyPress() { char key = keypad.getKey(); if (key) { lcd.clear(); lcd.print("U Pressed: "); lcd.print(key); } if (key == '1') { digitalWrite(a, HIGH); } else if (key == '2') { digitalWrite(b, HIGH); } else if (key == '3') { digitalWrite(c, HIGH); } else if (key == '4') { digitalWrite(d, HIGH); } else if (key == '5') { digitalWrite(e, HIGH); } else if (key == '6') { digitalWrite(f, HIGH); } else if (key == '7') { digitalWrite(g, HIGH); } else if (key == '8') { digitalWrite(p, HIGH); } } void loop() { keyPress(); }