#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Inisialisasi LCD I2C
const int button1Pin = 23; // Pin untuk button 1
const int button2Pin = 19; // Pin untuk button 2
bool button1State = false;
bool button2State = false;
void setup() {
lcd.init(); // Mulai LCD
lcd.backlight(); // Hidupkan backlight
pinMode(button1Pin, INPUT_PULLUP); // Atur button 1 sebagai input pull-up
pinMode(button2Pin, INPUT_PULLUP); // Atur button 2 sebagai input pull-up
lcd.print("Selamat Datang"); // Tampilkan pesan awal
delay(2000); // Tunda 2 detik
lcd.clear();
lcd.print("Pilih button"); // Tampilkan instruksi
}
void loop() {
button1State = digitalRead(button1Pin) == LOW; // Cek button 1
button2State = digitalRead(button2Pin) == LOW; // Cek button 2
if (button1State) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Button 1");
for (int pos = 0; pos < 16; pos++) {
lcd.setCursor(pos, 0);
lcd.print("Button 1"); // Tampilkan "Button 1"
delay(200); // Tunda untuk efek geser
lcd.clear(); // Bersihkan LCD untuk update
}
}
if (button2State) {
lcd.clear();
lcd.setCursor(15, 1);
lcd.print("Button 2");
for (int pos = 15; pos >= 0; pos--) {
lcd.setCursor(pos, 1);
lcd.print("Button 2"); // Tampilkan "Button 2"
delay(200); // Tunda untuk efek geser
lcd.clear(); // Bersihkan LCD untuk update
}
}
}