TimeAlarms Library
源自於
http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
Hardware RequirementsTimeAlarms does not require any special hardware, because it uses the time and date provided by the Time library.Creating AlarmsAlarms are used to call a function at a specific time of the day.Alarm.alarmRepeat(hours, minutes, seconds, function);
Create an alarm that will call a function every day at a particular time.
Alarm.alarmRepeat(dayofweek, hours, minutes, seconds, function);
Create an alarm that will call a function every week on a specific day at a particular time.
Alarm.alarmOnce(hours, minutes, seconds, function);"dayofweek" can be dowSunday, dowMonday, dowTuesday, dowWednesday, dowThursday, dowFriday, or dowSaturday.
Create an alarm that will call a function tomorrow at a particular time.
Alarm.alarmOnce(dayofweek, hours, minutes, seconds, function);
Create an alarm that will call a function once, at specific day and time.
Creating TimersTimers call a function at regular intervals.Alarm.timerRepeat(seconds, function);
Create a timer that will call a function every at an interval of "seconds".
Alarm.timerOnce(seconds, function);
Create a timer that will call a function once in "seconds".
Normal Running UsageAlarm.delay(milliseconds);
Alarms and Timers are only checks and their functions called when you use this delay function. You can pass 0 for minimal delay. This delay should be used instead of the normal Arduino delay(), for timely processing of alarms and timers.
Example ProgramYou can open this example from File > Examples > TimeAlarms > TimeAlarmExample./* * TimeAlarmExample.pde * * This example calls alarm functions at 8:30 am and at 5:45 pm (17:45) * and simulates turning lights on at night and off in the morning * A weekly timer is set for Saturdays at 8:30:30 * * A timer is called every 15 seconds * Another timer is called once only after 10 seconds * * At startup the time is set to Jan 1 2011 8:29 am */ #include <Time.h> #include <TimeAlarms.h> void setup() { Serial.begin(9600); setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011 // create the alarms Alarm.alarmRepeat(8,30,0, MorningAlarm); // 8:30am every day Alarm.alarmRepeat(17,45,0,EveningAlarm); // 5:45pm every day Alarm.alarmRepeat(dowSaturday,8,30,30,WeeklyAlarm); // 8:30:30 every Saturday Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds Alarm.timerOnce(10, OnceOnly); // called once after 10 seconds } void loop(){ digitalClockDisplay(); Alarm.delay(1000); // wait one second between clock display } // functions to be called when an alarm triggers: void MorningAlarm(){ Serial.println("Alarm: - turn lights off"); } void EveningAlarm(){ Serial.println("Alarm: - turn lights on"); } void WeeklyAlarm(){ Serial.println("Alarm: - its Monday Morning"); } void ExplicitAlarm(){ Serial.println("Alarm: - this triggers only at the given date and time"); } void Repeats(){ Serial.println("15 second timer"); } void OnceOnly(){ Serial.println("This timer only triggers once"); } void digitalClockDisplay() { // digital clock display of the time Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.println(); } void printDigits(int digits) { Serial.print(":"); if(digits < 10) Serial.print('0'); Serial.print(digits); } |
2015年7月26日 星期日
Arduino TimeAlarms Library
訂閱:
張貼留言 (Atom)
WOKWI DHT22 & LED , Node-Red + SQLite database
WOKWI DHT22 & LED , Node-Red + SQLite database Node-Red程式 [{"id":"6f0240353e534bbd","type":"comment&...
-
python pip 不是内部或外部命令 -- 解決方法 要安裝 Pyqt5 1. 首先,開啟命令提示字元。 2. 輸入 pip3 install pyqt5 好像不能執行 ! ! 錯誤顯示 : ‘ pip3 ’ 不是內部或外部命令、可執行的程式或批...
-
課程講義 下載 11/20 1) PPT 下載 + 程式下載 http://www.mediafire.com/file/cru4py7e8pptfda/106%E5%8B%A4%E7%9B%8A2-1.rar 11/27 2) PPT 下載...
-
• 認 識 PreFix、InFix、PostFix PreFix(前序式):* + 1 2 + 3 4 InFix(中序式): (1+2)*(3+4) PostFix(後序式):1 2 + 3 4 + * 後 序式的運算 例如: 運算時由 後序式的...
沒有留言:
張貼留言