Hi There , I Just want to use multiple AlaramId as description in TimeAlarm.h Library in section
Low level functions not usually required for typical applications:
disable( ID); - prevent the alarm associated with the given ID from triggering
enable(ID); - enable the alarm
Due to minimum example that using Multiple AlarmId,
I have try the included example and modification to use 2 AlarmID , but does not work
here is the modification
#include <TimeLib.h>
#include <TimeAlarms.h>
AlarmId id1;
AlarmId id2;
void setup() {
Serial.begin(9600);
while (!Serial) ; // wait for Arduino Serial Monitor
setTime(8,00,0,7,30,21); // set time to Saturday 8:29:00am Jan 1 2011
// create the alarms, to trigger at specific times
id2= 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
// create timers, to trigger relative to when they're created
Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds
id1 = Alarm.timerRepeat(2, Repeats2); // timer for every 2 seconds
Alarm.timerOnce(10, OnceOnly); // called once after 10 seconds
AlarmId.disable(id1);
AlarmId.enable(id2);
}
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 Repeats2() {
Serial.println("2 second timer");
}
void OnceOnly() {
Serial.println("This timer only triggers once, stop the 2 second timer");
// use Alarm.free() to disable a timer and recycle its memory.
//Alarm.free(id);
// optional, but safest to "forget" the ID after memory recycled
//id = dtINVALID_ALARM_ID;
// you can also use Alarm.disable() to turn the timer off, but keep
// it in memory, to turn back on later with Alarm.enable().
}
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);
}`
AlarmId id1 effected by AlarmId id2 and vise versa , when trying to disable one of them.
Any help or solved LINK are appreciate.
Thanks