#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(300);
lcd.setCursor(16, 0);
lcd.print("Lampu Hidup");
lcd.scrollDisplayLeft();
delay(300);
}
else {
digitalWrite(ledred, LOW);
delay(300);
lcd.setCursor(16,0);
lcd.print("Lampu Mati");
lcd.scrollDisplayLeft();
delay(300);
}
}