//______________________________________________________
//==========TUGAS 2_PROGRAM KEYPAD DAN LCD I2C==========
//______________________________________________________
//NAMA : NABILA HASNA RIZQI NURFADHILLAH
//NIM : 2103411036
//NO.ABSEN : 19
//KELAS : TOLI 3B
//______________________________________________________
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 4);
const uint8_t ROWS = 4;
const uint8_t COLS = 4;
char keys[ROWS][COLS] = {
{ '1', '2', '3', 'A' },
{ '4', '5', '6', 'B' },
{ '7', '8', '9', 'C' },
{ '*', '0', '#', 'D' }
};
uint8_t colPins[COLS] = { 12, 5, 4, 2 }; // Pins connected to C1, C2, C3, C4
uint8_t rowPins[ROWS] = { 18, 15, 14, 13 }; // Pins connected to R1, R2, R3, R4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
lcd.init();
lcd.backlight();
lcd.setCursor(6,0);
lcd.print("TUGAS 2");
}
void loop() {
char key = keypad.getKey();
if (key != NO_KEY) {
lcd.setCursor(0,2);
lcd.print(key);
}
}