Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d5902f8

Browse files
committedJul 10, 2024·
improving the example
1 parent 4369a06 commit d5902f8

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed
 

‎libraries/RTC/examples/Test_RTC/Test_RTC.ino

Lines changed: 5 additions & 11 deletions
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)
Please sign in to comment.