#include <LiquidCrystal.h> // Include the LCD library
const int rs = PB11, en = PB10, d4 = PB0, d5 = PB1, d6 = PC13, d7 = PC14; // Pin konfigurasi LCD
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); // Initialize the LCD
unsigned long currentTime = 0;
unsigned long startTime = 0;
void setup() {
lcd.begin(16, 2); // Inisialisasi LCD 16x2
lcd.setCursor(0, 0); // Baris pertama, kolom pertama
lcd.print("Start :"); // Tampilkan teks pertama
delay(2000); // Tunggu 2 detik
lcd.clear(); // Bersihkan layar
startTime = millis(); // Mulai hitungan waktu
}
void loop() {
// Hitung waktu berjalan dalam milidetik
currentTime = millis();
// Hitung detik berjalan dengan kecepatan 3 kali lipat
unsigned long fastSeconds = (currentTime - startTime) / (1000 / 3);
// Tampilkan detik berjalan di LCD
lcd.setCursor(0, 0); // Baris pertama
lcd.print("Seconds: ");
lcd.setCursor(9, 0); // Baris pertama kolom ke-10
lcd.print(fastSeconds); // Tampilkan detik berjalan
delay(100); // Update tampilan setiap 100 ms untuk menjaga akurasi
}
Loading
stm32-bluepill
stm32-bluepill