Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <DS3231.h>
- DS3231 clock;
- RTCDateTime dt;
- int alarmLED = 4;
- void alarmFunction()
- {
- digitalWrite(alarmLED, HIGH);
- delay(1000);
- digitalWrite(alarmLED, LOW);
- delay(1000);
- }
- void setup()
- {
- Serial.begin(9600);
- // Initialize DS3231
- Serial.println("Initialize DS3231");;
- clock.begin();
- // Disarm alarms and clear alarms for this example, because alarms is battery backed.
- // Under normal conditions, the settings should be reset after power and restart microcontroller.
- clock.armAlarm1(false);
- clock.armAlarm2(false);
- clock.clearAlarm1();
- clock.clearAlarm2();
- // Set Alarm1 - Every 10s in each minute
- // setAlarm1(Date or Day, Hour, Minute, Second, Mode, Armed = true)
- clock.setAlarm1(0, 0, 0, 10, DS3231_MATCH_S);
- // Attach Interrput 0. In Arduino UNO connect DS3231 INT to Arduino Pin 2
- attachInterrupt(0, alarmFunction, FALLING);
- // Setup LED Pin
- pinMode(alarmLED, OUTPUT);
- }
- void loop()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement