#include <LiquidCrystal.h>
// Inisialisasi pin untuk LCD
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Tombol
const int button1 = A0; // Tombol untuk pause/resume
const int button2 = A1; // Tombol untuk restart pesan
bool isPaused = false; // Status pause
void setup() {
pinMode(button1, INPUT_PULLUP); // Tombol pause/resume
pinMode(button2, INPUT_PULLUP); // Tombol restart
lcd.begin(16, 2); // Atur ukuran LCD
lcd.print("jadwal sholat"); // Teks awal
delay(2000); // Tahan sebentar sebelum scrolling dimulai
}
void loop() {
static String message = "subuh 03.34 , dhuhur 11.17 , ashar 14.44 , magrib 17.35 , isya 18.52 ";
static int position = 0; // Posisi scroll
// Periksa tombol pause/resume
if (digitalRead(button1) == LOW) {
delay(200); // Debounce
isPaused = !isPaused; // Ubah status pause
}
// Periksa tombol restart
if (digitalRead(button2) == LOW) {
delay(200); // Debounce
position = 0; // Reset posisi scroll
}
// Jika tidak pause, lakukan scrolling
if (!isPaused) {
lcd.clear();
lcd.print(message.substring(position, position + 16)); // Tampilkan teks sesuai posisi
position++; // Geser posisi
if (position >= message.length()) position = 0; // Ulangi dari awal
delay(300); // Kecepatan scrolling
}
}