#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lol(0x27, 20, 4);
int ld = 7;
void setup() {
lol.init(); // put your setup code here, to run once:
lol.backlight();
lol.setCursor(3, 1);
lol.print("Lampu LED");
pinMode(6, INPUT_PULLUP);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop() {
delay(100); // put your main code here, to run repeatedly:
if (digitalRead(6) == 0) {
ld++;
digitalWrite(ld, 1);
}
if (ld == 12) {
digitalWrite(8, 0);
digitalWrite(9, 0);
digitalWrite(10, 0);
digitalWrite(11, 0);
}
if (ld == 8 && digitalRead(6) == 0) {
lol.clear();
lol.setCursor(3, 0);
lol.print("Lampu Merah");
lol.setCursor(4, 1);
lol.print("Menyala");
}
if (ld == 9 && digitalRead(6) == 0) {
lol.clear();
lol.setCursor(3, 0);
lol.print("Lampu Kuning");
lol.setCursor(4, 1);
lol.print("Menyala");
}
if (ld == 10 && digitalRead(6) == 0) {
lol.clear();
lol.setCursor(3, 0);
lol.print("Lampu Hijau");
lol.setCursor(4, 1);
lol.print("Menyala");
}
if (ld == 11 && digitalRead(6) == 0) {
lol.clear();
lol.setCursor(3, 0);
lol.print("Lampu Biru");
lol.setCursor(4, 1);
lol.print("Menyala");
}
if (ld == 12 && digitalRead(6) == 0) {
ld = 7;
lol.clear();
lol.setCursor(3, 0);
lol.print("All lampu off");
}
}