#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C myLCD(0x27,16,2);
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {11, 10, 9, 8};
byte colPins[COLS] = {7, 6, 5, 4};
Keypad myKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
myLCD.begin(16,2);
myLCD.clear();
myLCD.backlight();
myLCD.setCursor(0,0);
Serial.begin(115200);
}
int baris = 0;
int kolom = 0;
void loop(){
char tombol = myKeypad.getKey();
if (tombol){
myLCD.setCursor(kolom,baris);
myLCD.print(tombol);
Serial.print(tombol);
kolom++;
if (kolom>15) {
baris++;
kolom=0;
}
if (baris>1) {
myLCD.clear();
baris=0;
kolom=0;
}
}
delay(10);
}