-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclock
More file actions
38 lines (30 loc) · 768 Bytes
/
clock
File metadata and controls
38 lines (30 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <Wire.h>
#include <RTClib.h>
RTC_PCF8523 rtc;
void setup() {
// Initialize the I2C communication
Wire.begin();
Serial.begin(9600);
// Initialize the RTC
rtc.begin();
// Set the current time and date on the RTC
}
void loop() {
// Read the time and date from the RTC
DateTime now = rtc.now();
// Print the time and date to the serial monitor
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
// Wait for one second before reading the time and date again
delay(1000);
}