Skip to content

Commit 06f704c

Browse files
improving the example
1 parent 98010c4 commit 06f704c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

libraries/RTC/examples/Test_RTC/Test_RTC.ino

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Test RTC
33
4-
A test sketch showcasing all RTC showcasing various functionalities related to the RTC module,
4+
A test sketch showcasing all RTC functionalities related to the RTC module,
55
including setting the time, handling interrupts, and reading time values.
66
77
Find the full UNO R4 WiFi RTC documentation here:
@@ -45,16 +45,10 @@ void setup() {
4545
// Set a specific initial time (August 25, 2022, 14:37:00 Thursday)
4646
RTCTime mytime(25, Month::AUGUST, 2022, 14, 37, 00, DayOfWeek::THURSDAY, SaveLight::SAVING_TIME_ACTIVE);
4747

48-
RTCTime savedTime;
49-
RTC.getTime(savedTime);
50-
51-
// Set the initial time if RTC is not running
48+
// Set the initial time if RTC is not running.
49+
// The RTC may be still running if the board was reset, or if VRTC pin was powered
5250
if (!RTC.isRunning()) {
53-
if (savedTime.getYear() != 2000) {
54-
RTC.setTime(mytime);
55-
} else {
56-
RTC.setTime(savedTime);
57-
}
51+
RTC.setTime(mytime);
5852
}
5953

6054
// Create an alarm time set to 35 seconds
@@ -147,4 +141,4 @@ void loop() {
147141

148142
status = !status;
149143
delay(1000);
150-
}
144+
}

0 commit comments

Comments
 (0)