File tree 5 files changed +75
-1
lines changed
5 files changed +75
-1
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ Simple RTC Alarm for Arduino Zero
3
+
4
+ Demonstrates the use an alarm to wake up an Arduino zero from Standby mode
5
+
6
+ This example code is in the public domain
7
+
8
+ http://arduino.cc/en/Tutorial/SleepRTCAlarm
9
+
10
+ created by Arturo Guadalupi
11
+ 17 Nov 2015
12
+ */
13
+
14
+ #include < RTCZero.h>
15
+
16
+ /* Create an rtc object */
17
+ RTCZero rtc;
18
+
19
+ /* Change these values to set the current initial time */
20
+ const uint8_t seconds = 0 ;
21
+ const uint8_t minutes = 00 ;
22
+ const uint8_t hours = 17 ;
23
+
24
+ /* Change these values to set the current initial date */
25
+ const uint8_t day = 17 ;
26
+ const uint8_t month = 11 ;
27
+ const uint8_t year = 15 ;
28
+
29
+ void setup ()
30
+ {
31
+ Serial.begin (115200 );
32
+
33
+ rtc.begin ();
34
+
35
+ rtc.setTime (hours, minutes, seconds);
36
+ rtc.setDate (day, month, year);
37
+
38
+ rtc.setAlarmTime (17 , 00 , 10 );
39
+ rtc.enableAlarm (rtc.MATCH_HHMMSS );
40
+
41
+ rtc.attachInterrupt (alarmMatch);
42
+
43
+ rtc.standbyMode ();
44
+ }
45
+
46
+ void loop ()
47
+ {
48
+
49
+ Serial.println (" Awake!" );
50
+
51
+ for (int i = 0 ; i < 10 ; i++)
52
+ Serial.print (i);
53
+
54
+ Serial.println ();
55
+
56
+ Serial.println (" Done! Goodnight!" );
57
+
58
+ rtc.standbyMode (); // Sleep until next alarm match
59
+ }
60
+
61
+ void alarmMatch ()
62
+ {
63
+
64
+ }
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ setAlarmTime KEYWORD2
47
47
enableAlarm KEYWORD2
48
48
disableAlarm KEYWORD2
49
49
50
+ standbyMode KEYWORD2
51
+
50
52
#######################################
51
53
# Constants (LITERAL1)
52
54
#######################################
Original file line number Diff line number Diff line change 1
1
name =RTCZero
2
- version =1.2 .0
2
+ version =1.3 .0
3
3
author =Arduino
4
4
maintainer =Arduino <
[email protected] >
5
5
sentence =Allows to use the RTC functionalities. For Arduino Zero only.
Original file line number Diff line number Diff line change @@ -100,6 +100,12 @@ void RTCZero::detachInterrupt()
100
100
RTC_callBack = NULL ;
101
101
}
102
102
103
+ void RTCZero::standbyMode ()
104
+ {
105
+ SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
106
+ __WFI ();
107
+ }
108
+
103
109
/*
104
110
* Get Functions
105
111
*/
Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ class RTCZero {
49
49
void attachInterrupt (voidFuncPtr callback);
50
50
void detachInterrupt ();
51
51
52
+ void standbyMode ();
53
+
52
54
/* Get Functions */
53
55
54
56
uint8_t getSeconds ();
You can’t perform that action at this time.
0 commit comments