#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Alamat I2C
const int buttonPin1 = 2; // Tombol 1
const int buttonPin2 = 3; // Tombol 2
const int ledPin = 7; // LED
int buttonState1 = 0;
int buttonState2 = 0;
void setup() {
lcd.begin(16, 2);
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Press a button");
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
}
void loop() {
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
if (buttonState1 == LOW) {
lcd.setCursor(0, 0);
lcd.print(" Lampu Padam ");
digitalWrite(ledPin, LOW);
}
if (buttonState2 == LOW) {
lcd.setCursor(0, 0);
lcd.print(" Lampu Nyala ");
digitalWrite(ledPin,HIGH);
}
}