#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
#include <Dht.h>
LiquidCrystal_I2C lcd (0x27, 16, 2);
const uint8_t x= 4;
const uint8_t y= 4;
uint8_t pinBaris [x] ={9,8,7,6};
uint8_t pinKolom[y] ={5,4,3,2};
char keys [x][y] = {{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}};
Keypad K = Keypad(makeKeymap(keys),pinBaris,pinKolom,x,y);
String PINTersimpan = "1589";
String PINTerinput = "";
bool kesesuaianPIN = false;
void selamatDatang () {
lcd.clear();
lcd.setCursor(0,0);
lcd.print("welcome");
lcd.setCursor(0,1);;
lcd.print("PIN:");
}
void setup() {
Serial.begin(115200);
dht.begin();
lcd.init();
lcd.backlight();
selamatDatang();
while (!kesesuaianPIN) {
char bacaKey = K.getKey();
if (bacaKey != NO_KEY) {
if (bacaKey =='D'){
if (PINTersimpan == PINTerinput) {
'kesesuainPIN'= true;
}
}else {
PINTerinput = PINTerinput + bacaKey;
Serial.println(bacaKey);
lcd.print(bacaKey);
}
}
}
}
void loop() {
float t = dht.readTemperatur();
float h = dht.reeadHumidity();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("temp :" + string(t) + "'c")
lcd.setCursor(0,1);
lcd.print("temp :" + string(h) + "%")
lcd.print("berhasil login");
delay(200);
}