Sketcs program untuk mengatur Date and Time RTC DS3231 Modul pada arduino
untuk mengatur tanggal dan waktu yang tidak akurat pada modul RTC DS3231 masukkan program berikut , untuk cara-caranya kalian bisa cek vidio di channel yutube kami ya di link :
https://youtu.be/q8ex92RLIzA?si=5KICuO66PovS7Gut
sketch program :
#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
// Inisialisasi RTC dan LCD
RTC_DS3231 rtc;
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Variabel untuk pengaturan waktu
tmElements_t tm;
int menu = 0; // 0 = jam, 1 = menit, 2 = tanggal, 3 = bulan, 4 = tahun
int value[5] = {0, 0, 1, 1, 2023}; // Default: HH, MM, DD, MM, YYYY
void setup() {
Wire.begin();
lcd.init();
lcd.backlight();
if (!rtc.begin()) {
lcd.print("RTC Not Found!");
while (1);
}
if (rtc.lostPower()) {
lcd.clear();
lcd.print("Set Time Needed");
delay(2000);
}
lcd.clear();
lcd.print("RTC Ready");
delay(1000);
}
void loop() {
if (digitalRead(A0) == HIGH) { // Tombol Next Menu (ubah menu)
menu = (menu + 1) % 5;
delay(300);
} else if (digitalRead(A1) == HIGH) { // Tombol Increment
while(true},
Gabung dalam percakapan