a_guadalupi:
Hi, you are on the right way, but with a trick.
You have to use the MATCH_MMSS but in the callback attached to the alarm you have to shift the alarm.
When the alarm is matched you have to use the setAlarmTime function in such a way:
void setup(){
....
....
setAlarmTime(xx, 0, xx); //your starting time
...
...
}
void alarmMatch(){
int alarmMinutes = rtc.getMinutes();
alarmMinutes += 15;
if (alarmMinutes >= 60){
alarmMinutes -= 60;
}
setAlarmTime(rtc.getHours(), alarmMinutes, rtc.getSeconds());
}
Thanks for the trick. But there is something strange, it seems not executing more than one line in the alarmMatch void. For example I tried led blinking every minute and it does not switch it off. The board put led HIGH at first alarm and doesn not put it LOW after delay(500). Here is the example:
#include <RTCZero.h>
/* Create an rtc object */
RTCZero rtc;
/* Change these values to set the current initial time */
const byte seconds = 0;
const byte minutes = 05;
const byte hours = 12;
/* Change these values to set the current initial date */
const byte day = 12;
const byte month = 01;
const byte year = 17;
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
rtc.begin();
rtc.setTime(hours, minutes, seconds);
rtc.setDate(day, month, year);
rtc.setAlarmTime(12, 06, 00);
rtc.enableAlarm(rtc.MATCH_MMSS);
rtc.attachInterrupt(alarmMatch);
rtc.standbyMode();
}
void loop()
{
rtc.standbyMode(); // Sleep until next alarm match
}
void alarmMatch()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
int alarmMinutes = rtc.getMinutes();
alarmMinutes += 1;
if (alarmMinutes >= 60){
alarmMinutes -= 60;
}
rtc.setAlarmTime(rtc.getHours(), alarmMinutes, rtc.getSeconds());
}