Difference between revisions of "Arduino: DS1307 RTC I2C Setup"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) (Created page with "Sumber: http://www.labelektronika.com/2018/02/cara-program-rtc-ds1307-menggunakan-Arduino.html center|400px|thumb RTC DS1307...") |
Onnowpurbo (talk | contribs) |
||
Line 8: | Line 8: | ||
VCC +5V | VCC +5V | ||
GND Gnd | GND Gnd | ||
+ | |||
+ | Library | ||
+ | |||
+ | https://github.com/adafruit/RTClib | ||
+ | |||
Latest revision as of 20:00, 2 April 2023
Sumber: http://www.labelektronika.com/2018/02/cara-program-rtc-ds1307-menggunakan-Arduino.html
RTC DS1307 Arduino SCL A5 SDA A4 VCC +5V GND Gnd
Library
https://github.com/adafruit/RTClib
Code
#include <Wire.h> #include "RTClib.h" RTC_DS1307 rtc; char namaHari[7][12] = {"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"}; void setup () { Serial.begin(9600); if (! rtc.begin()) { Serial.println("RTC TIDAK TERBACA"); while (1); } if (! rtc.isrunning()) { Serial.println("RTC is NOT running!"); rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));//update rtc dari waktu komputer } } void loop () { DateTime now = rtc.now(); Serial.print(namaHari[now.dayOfTheWeek()]); Serial.print(','); Serial.print(now.day(), DEC); Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.year(), DEC); Serial.print(" "); Serial.print(now.hour(), DEC); Serial.print(':'); Serial.print(now.minute(), DEC); Serial.print(':'); Serial.print(now.second(), DEC); Serial.println(); delay(3000); }