Skip to content

Commit 30017ab

Browse files
committed
added new example on Alarms and modified SimpleRTC
1 parent c6602a8 commit 30017ab

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

Diff for: examples/SimpleRTC/SimpleRTC.ino

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
88
http://arduino.cc/en/Tutorial/SimpleRTC
99
10+
created by Arturo Guadalupi <[email protected]>
11+
15 Jun 2015
1012
*/
1113

1214
#include <RTCZero.h>

Diff for: examples/SimpleRTCAlarm/SimpleRTCAlarm.ino

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Simple RTC Alarm for Arduino Zero
3+
4+
Demonstrates the use of alarms using the RTC library for the Arduino Zero
5+
6+
This example code is in the public domain
7+
8+
http://arduino.cc/en/Tutorial/SimpleRTCAlarm
9+
10+
created by Arturo Guadalupi <[email protected]>
11+
25 Sept 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 = 0;
22+
const uint8_t hours = 17;
23+
24+
/* Change these values to set the current initial date */
25+
const uint8_t day = 25;
26+
const uint8_t month = 9;
27+
const uint8_t year = 15;
28+
29+
void setup()
30+
{
31+
Serial.begin(9600);
32+
33+
rtc.begin(H24); // initialize RTC 24H format. The dual option is H12
34+
35+
rtc.setTime(hours, minutes, seconds);
36+
rtc.setDate(day, month, year);
37+
38+
rtc.setAlarmTime(16, 0, 10);
39+
rtc.enableAlarm(rtc.MATCH_HHMMSS);
40+
41+
rtc.attachInterrupt(alarmMatch);
42+
}
43+
44+
void loop()
45+
{
46+
47+
}
48+
49+
void alarmMatch()
50+
{
51+
Serial.println("Alarm Match!");
52+
}

0 commit comments

Comments
 (0)