-
Notifications
You must be signed in to change notification settings - Fork 6
setAlarm()
Arnd edited this page Dec 12, 2020
·
2 revisions
SetAlarm(alarmType, alarmDate [,alarmState])
This function is called to set an alarm. The state of the alarm is checked with isAlarm().
The function is called with a key value for the alarm type to be set followed by a dateTimeClass containing the time when the alarm should go off. The "alarmState" is an optional parameter which defaults to "true" and specifies if the alarm is to be activated once set.
AlarmType | Description |
---|---|
everySecond | Alarm goes off every second |
secondsMatch | Alarm goes off when seconds match |
secondsMinutesMatch | Alarm goes off when seconds and minutes match |
secondsMinutesHoursMatch | Alarm goes off when seconds, minutes and hours match |
secondsMinutesHoursDateMatch | Alarm goes off when seconds, minutes, hours and Day-of-Month match |
secondsMinutesHoursDayMatch | Alarm goes off when seconds, minutes, hours and Day-of-Week match |
everyMinute | Alarm goes off every minute when the time reaches 00 seconds |
minutesMatch | Alarm goes off when minutes match |
minutesHoursMatch | Alarm goes off when minutes and hours match |
minutesHoursDateMatch | Alarm goes off when minutes, hours and Day-of-Month match |
minutesHoursDayMatch | Alarm goes off when minutes, hours and Day-of-Week match |
...
DS3231M_Class DS3231M; // Create an instance of the DS3231M
...
void setup() {
Serial.begin(SERIAL_SPEED);
while (!DS3231M.begin()) { // Initialize RTC communications
Serial.println("Unable to find DS3231M. Checking again in 1 second.");
delay(1000);
} // of loop until device is located
uint8_t alarmType;
DS3231M.setAlarm(secondsMinutesHoursDateMatch,DateTime(2017,8,5,18,30,0)); // 18:30:00 on 2017-08-05
while (!DS3231M.isAlarm()); // loop until the alarm is triggered
DS3231M.clearAlarm(); // Turn off the alarm
...