Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.99 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <DS3231.h>
  3.  
  4. DS3231 clock;
  5. RTCDateTime dt;
  6. int alarmLED = 4;
  7.  
  8. void alarmFunction()
  9. {
  10.   digitalWrite(alarmLED, HIGH);
  11.   delay(1000);
  12.   digitalWrite(alarmLED, LOW);
  13.   delay(1000);  
  14. }
  15.  
  16. void setup()
  17. {
  18.   Serial.begin(9600);
  19.  
  20.   // Initialize DS3231
  21.   Serial.println("Initialize DS3231");;
  22.   clock.begin();
  23.  
  24.   // Disarm alarms and clear alarms for this example, because alarms is battery backed.
  25.   // Under normal conditions, the settings should be reset after power and restart microcontroller.
  26.   clock.armAlarm1(false);
  27.   clock.armAlarm2(false);
  28.   clock.clearAlarm1();
  29.   clock.clearAlarm2();
  30.  
  31.   // Set Alarm1 - Every 10s in each minute
  32.   // setAlarm1(Date or Day, Hour, Minute, Second, Mode, Armed = true)
  33.   clock.setAlarm1(0, 0, 0, 10, DS3231_MATCH_S);
  34.  
  35.   // Attach Interrput 0. In Arduino UNO connect DS3231 INT to Arduino Pin 2
  36.   attachInterrupt(0, alarmFunction, FALLING);
  37.  
  38.   // Setup LED Pin
  39.   pinMode(alarmLED, OUTPUT);
  40. }
  41.  
  42. void loop()
  43. {
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement