#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16, 2);
void setup() {
lcd.init();
lcd.backlight();
#define button 4
#define ledred 3
pinMode(button, INPUT);
pinMode(ledred, OUTPUT );
}
void loop() {
int Switch_State=digitalRead(button);
if (Switch_State==HIGH){
digitalWrite(ledred, HIGH);
delay(500);
lcd.setCursor(0,0);
lcd.print("Lampu Hidup");
delay(300);
lcd.scrollDisplayLeft();
}
else{
digitalWrite(ledred, LOW);
delay(500);
lcd.setCursor(0,1);
lcd.print("Lampu Mati");
delay(300);
lcd.scrollDisplayLeft();
}
}