#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int buttonPin = 6; // Pin tempat tombol terhubung
int buttonState = 0; // Status tombol
void setup() {
lcd.begin(16, 2);
pinMode(buttonPin, INPUT_PULLUP); // Mengatur pin tombol sebagai input dengan pull-up resistor
lcd.print("Teknik Elektro"); // Menampilkan teks awal pada line pertama
lcd.setCursor(0, 1);
lcd.print("SV UGM"); // Menampilkan teks awal pada line kedua
delay(2000); // Tunggu 2 detik
lcd.clear(); // Hapus layar LCD
}
void loop() {
buttonState = digitalRead(buttonPin); // Baca status tombol
if (buttonState == LOW) { // Jika tombol ditekan
scrollLeftAndRight();
}
}
void scrollLeftAndRight() {
lcd.setCursor(0, 0); // Atur kursor ke baris pertama
lcd.print("Teknik Elektro"); // Tampilkan teks awal pada line pertama
lcd.setCursor(0, 1); // Atur kursor ke baris kedua
lcd.print("SV UGM"); // Tampilkan teks awal pada line kedua
delay(1000); // Tunggu 1 detik
for (int i = 0; i < 12; i++) {
lcd.scrollDisplayLeft(); // Geser teks ke kiri
delay(500); // Tunggu setengah detik
}
delay(1000); // Tunggu 1 detik
for (int i = 0; i < 12; i++) {
lcd.scrollDisplayRight(); // Geser teks ke kanan
delay(500); // Tunggu setengah detik
}
lcd.clear(); // Hapus layar LCD
}