Skip to content

Commit a408fbf

Browse files
committed
RTC
1 parent 2f12488 commit a408fbf

File tree

1 file changed

+53
-9
lines changed
  • content/hardware/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet

1 file changed

+53
-9
lines changed

content/hardware/02.hero/boards/uno-r4-wifi/tutorials/cheat-sheet/cheat-sheet.md

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ value = analogRead(pin, value);
132132

133133
The reference voltage of these pins is 3.3V.
134134

135+
### OPAMP Pins
136+
137+
The **RA4M1** has an internal OPAMP that is exposed on the **UNO R4 WiFi** as follows:
138+
139+
| Pin | OPAMP |
140+
| --- | --------- |
141+
| A1 | OPAMP + |
142+
| A2 | OPAMP - |
143+
| A3 | OPAMP OUT |
144+
135145
#### Additional PWM Pins
136146

137147
The following pins are PWM capable but may interfer with other functionalities of the UNO R4 WiFi board. When writing library functions, please do not use this as they are officially supported PWM pins.
@@ -196,9 +206,9 @@ You may use them as analog output pins with the function:
196206
analogWrite(pin, value);
197207
```
198208

199-
### DAC Pin
209+
## DAC
200210

201-
The **UNO R4 WiFi** also has a DAC pin (A0) that can act as genuine analog output pin which means it's even more capable than PWM pins.
211+
The **UNO R4 WiFi** also has a DAC with up to 12-bit resolution, that can act as genuine analog output pin which means it's even more capable than PWM pins.
202212

203213
```arduino
204214
analogWrite(pin, value);
@@ -214,15 +224,49 @@ However you may change this write resolution if you need to, to up to 12-bits, a
214224
analogWriteResolution(12);
215225
```
216226

217-
### OPAMP Pins
227+
## RTC
218228

219-
The **RA4M1** has an internal OPAMP that is exposed on the **UNO R4 WiFi** as follows:
229+
A real-time clock (RTC) is used to measure the time, and is useful in any time-tracking applications.
220230

221-
| Pin | OPAMP |
222-
| --- | --------- |
223-
| A1 | OPAMP + |
224-
| A2 | OPAMP - |
225-
| A3 | OPAMP OUT |
231+
Below is a minimal example that shows how to obtain the date and time from the RTC:
232+
233+
```arduino
234+
#include "RTC.h"
235+
236+
void setup() {
237+
Serial.begin(9600);
238+
239+
RTC.begin();
240+
RTCTime mytime(30, Month::JUNE, 2023, 13, 37, 00, DayOfWeek::WEDNESDAY, SaveLight::SAVING_TIME_ACTIVE);
241+
242+
RTC.setTime(mytime);
243+
}
244+
245+
void loop() {
246+
RTCTime currenttime;
247+
248+
// Get current time from RTC
249+
RTC.getTime(currenttime);
250+
251+
// Print out date (DD/MM//YYYY)
252+
Serial.print(currenttime.getDayOfMonth());
253+
Serial.print("/");
254+
Serial.print(Month2int(currenttime.getMonth()));
255+
Serial.print("/");
256+
Serial.print(currenttime.getYear());
257+
Serial.print(" - ");
258+
259+
// Print time (HH/MM/SS)
260+
Serial.print(currenttime.getHour());
261+
Serial.print(":");
262+
Serial.print(currenttime.getMinutes());
263+
Serial.print(":");
264+
Serial.println(currenttime.getSeconds());
265+
266+
delay(1000);
267+
}
268+
269+
```
226270

227271
## EEPROM
228272

0 commit comments

Comments
 (0)