#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
int LED = 12 ;
LiquidCrystal_I2C lcd(0x27 , 16 , 2);
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] = {9,8,7,6};
byte colPin[COLS] = {5,4,3,2};
Keypad keypad = Keypad(makeKeymap(keys), rowPin , colPin , ROWS , COLS);
void setup() {
// put your setup code here, to run once:
lcd.begin(16,2);
lcd.backlight();
lcd.print("Use KeyPad : ");
delay(2000);
lcd.clear();
lcd.setCursor(0,0);
pinMode(LED , OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
char keys = keypad.getKey();
if(keys) {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Entered : ");
lcd.print(keys);
digitalWrite(LED , HIGH);
delay(100);
digitalWrite(LED , LOW);
delay(100);
}
}