source: rtos_arduino/trunk/arduino_lib/libraries/RTC/examples/ALARM_polled/ALARM_polled.ino@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.5 KB
Line 
1/*********************************************************************************************************************************************************************************
2* This sketch demonstrates how configure alarm in polled mode.
3 In this mode you hav to check continuously ALARM0 flag in the main program code.
4*********************************************************************************************************************************************************************************/
5
6
7#include <RTCInt.h>
8
9RTCInt rtc;
10
11void setup()
12{
13 Serial.begin(9600); //serial communication initializing
14 pinMode(13,OUTPUT);
15 rtc.begin(TIME_H24); //RTC initializing with 24 hour representation mode
16 rtc.setTime(17,0,5,0); //setting time (hour minute and second)
17 rtc.setDate(13,8,15); //setting date
18 rtc.enableAlarm(SEC,ALARM_POLLED,NULL); //enabling alarm in polled mode and match on second
19 rtc.local_time.hour=17;
20 rtc.local_time.minute=5;
21 rtc.local_time.second=10; //setting second to match
22 rtc.setAlarm(); //write second in alarm register
23}
24
25void loop()
26{
27
28 digitalWrite(13,HIGH);
29 delay(100);
30 digitalWrite(13,LOW);
31 delay(400);
32
33 if(rtc.alarmMatch()) //when match occurs led on pin 13 blinks ten times
34 {
35 Serial.println("Alarm match!");
36 for(int i=0; i < 10; i++)
37 {
38 digitalWrite(13,HIGH);
39 delay(200);
40 digitalWrite(13,LOW);
41 delay(800);
42 }
43 RTC->MODE2.INTFLAG.bit.ALARM0=1; //clearing alarm0 flag
44 }
45
46}
Note: See TracBrowser for help on using the repository browser.