en-us_commands:reference:irtcsetalarm2
This is an old revision of the document!
Table of Contents
IrtcSetAlarm2()
IrtcSetAlarm2() sets alarm 2 with minute resolution.
bool IrtcSetAlarm2(uint8_t mode, uint8_t dayOrDate = 1, uint8_t hour = 0, uint8_t minute = 0)
Commands
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
IrtcSetAlarm2(mode, dayOrDate, hour, minute) | uint8_t modeuint8_t dayOrDate = 1uint8_t hour = 0 — 0~23uint8_t minute = 0 — 0~59 | bool | Sets alarm 2 with minute resolution. |
Example
void setup() { Serial.begin(115200); if (!IrtcBegin()) return; // Check the DS3231 RTC connection and begin operation. IrtcSetAlarm1(IRTC_ALARM1_MATCH_HOUR_MINUTE_SECOND, 1, 8, 30, 0); // Set alarm 1, including seconds. IrtcSetAlarm2(IRTC_ALARM2_MATCH_HOUR_MINUTE, 1, 17, 30); // Set alarm 2 with minute resolution. IrtcAlarmEnable(1, true); // Enable or disable the specified alarm. IrtcAlarmEnable(2, true); // Enable or disable the specified alarm. } void loop() { bool alarm1Enabled = false; bool alarm1Triggered = false; IrtcAlarmEnabled(1, alarm1Enabled); // Check whether the specified alarm is enabled. if (alarm1Enabled && IrtcAlarmTriggered(1, alarm1Triggered, true) && alarm1Triggered) { // Check whether an alarm has triggered and optionally clear its status. Serial.println(F("alarm 1")); } delay(50); }
Precautions
Run each device's corresponding Begin command first. Check I²C addresses and pin sharing; if the bool return value is false, inspect wiring and power.
en-us_commands/reference/irtcsetalarm2.1788791735.txt.gz · Last modified: by 127.0.0.1
