Skip to content

Commit 1d09eef

Browse files
committed
Update vrtc-off.md
1 parent 8176c5c commit 1d09eef

File tree

1 file changed

+34
-0
lines changed
  • content/hardware/02.hero/boards/uno-r4-wifi/tutorials/vrtc-off

1 file changed

+34
-0
lines changed

content/hardware/02.hero/boards/uno-r4-wifi/tutorials/vrtc-off/vrtc-off.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,40 @@ On the header that is located by the barrel jack, you'll find the VRTC pin. And
3737

3838
![Battery Pack Powering the UNO R4 WiFi RTC](./assets/Circuit.png)
3939

40+
The following sketch will start the RTC but only set the time if it is not already running.
41+
42+
```arduino
43+
#include "RTC.h"
44+
45+
void setup() {
46+
// put your setup code here, to run once:
47+
Serial.begin(9600);
48+
RTC.begin();
49+
RTCTime mytime(24, Month::MAY, 2023, 11, 8, 0, DayOfWeek::THURSDAY, SaveLight::SAVING_TIME_ACTIVE);
50+
51+
RTC.setTimeIfNotRunning(mytime);
52+
53+
}
54+
55+
void loop() {
56+
// put your main code here, to run repeatedly:
57+
58+
RTCTime currenttime;
59+
RTC.getTime(currenttime);
60+
61+
int hours = currenttime.getHour();
62+
int minutes = currenttime.getMinutes();
63+
64+
65+
Serial.print("Hours: ");
66+
Serial.println(hours);
67+
Serial.println("Minutes: ");
68+
Serial.println(minutes);
69+
70+
}
71+
72+
```
73+
4074
## OFF Pin
4175
The OFF pin on the Arduino UNO R4 WiFi board lets you turn the boards onboard 5 V power supply off, basically turning off the board.
4276

0 commit comments

Comments
 (0)