Dear All,
Maybe you have noticed, the MATCH_SS timer fires every minute. For those of you who want to use a one second timer, here is a small work around:
#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 = 00; const byte hours = 0;
/* Change these values to set the current initial date */ const byte day = 1; const byte month = 1; const byte year = 1;
volatile bool IRQ_Timer;
int secs = 1;
void setup() { while ((!SerialUSB) && (millis() < 5000)) { } delay(3000);
pinMode(2, OUTPUT);
IRQ_Timer = false;
rtc.begin();
rtc.setTime(hours, minutes, seconds); rtc.setDate(day, month, year); rtc.enableAlarm(RTCZero::MATCH_SS); rtc.setAlarmSeconds(secs++); rtc.attachInterrupt(alarmMatch); }
void loop() { if (IRQ_Timer) { IRQ_Timer = false;
rtc.setAlarmSeconds(secs);
if (++secs == 60) secs = 0;
SerialUSB.println(rtc.getAlarmSeconds()); }
}
void alarmMatch() { IRQ_Timer = true; }
Have fun,
Axel