You can get the value of an alarm using the Alarm.read method.
This method will return the alarm value (or zero if the alarm is not allocated).
Values less than or equal to the number of seconds per day (SECS_PER_DAY) are alarms that will repeat each day (when the elapsed seconds in the day is equal to the value). Values greater than SECS_PER_DAY are treated as absolute times and will trigger once only at that given time and date.
Here is a modified version of the example sketch that illustrates the use of Alarm.read
#include <Time.h>
#include <TimeAlarms.h>
AlarmID_t firstAlarm;
AlarmID_t secondAlarm;
void setup()
{
Serial.begin(9600);
setTime(8,29,40,1,1,10); // set time to 8:29:40am Jan 1 2010
firstAlarm = Alarm.alarmRepeat(8,30,0, MorningAlarm); // 8:30am every day
secondAlarm = Alarm.alarmRepeat(17,45,0,EveningAlarm); // 5:45pm every day
}
void MorningAlarm()
{
Serial.println("Alarm: - turn lights off");
}
void EveningAlarm()
{
Serial.println("Alarm: - turn lights on");
}
void loop()
{
time_t t = now();
digitalClockDisplay(t);
Alarm.delay(1000); // wait one second between clock display
showAlarmTime(firstAlarm);
showAlarmTime(secondAlarm);
}
void showAlarmTime(AlarmID_t id)
{
time_t alarmTime = Alarm.read(id);
if(alarmTime!= 0)
{
if( alarmTime <= SECS_PER_DAY)
Serial.print(" repeat alarm with ID ");
else
Serial.print(" once only alarm with ID ");
Serial.print(id, DEC);
Serial.print(" set for ");
digitalClockDisplay(alarmTime);
}
}
void digitalClockDisplay(time_t t)
{
// digital clock display of the time
Serial.print(hour(t));
printDigits(minute(t));
printDigits(second(t));
Serial.println();
}
void printDigits(int digits)
{
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
the output will look like this:
8:29:40
repeat alarm with ID 0 set for 8:30:00
repeat alarm with ID 1 set for 17:45:00
(The time and companion TimeAlarms libraries can be downloaded from here:
http://www.arduino.cc/playground/Code/Time)