SHARE
TWEET

Untitled

a guest Apr 21st, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. GND -> GND
  3. VCC -> 5V
  4. SDA -> 20SDA
  5. SCL -> 21SCL
  6. */
  7.  
  8. #include <Wire.h>
  9. #include "RTClib.h"
  10.  
  11.  
  12. DateTime now;
  13.  
  14. char daysOfTheWeek[7][12] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
  15.  
  16. RTC_DS3231 rtc;
  17.  
  18. void showDate(void);
  19. void showTime(void);
  20. void showDay(void);
  21.  
  22.  
  23. void setup ()
  24. {
  25.   Serial.begin(9600);
  26.  
  27.   //delay(2000);
  28.   if (! rtc.begin())
  29.   {
  30.     Serial.println("Couldn't find RTC Module");
  31.     while (1);
  32.   }
  33.  
  34.   if (rtc.lostPower())
  35.   {
  36.     Serial.println("RTC lost power, lets set the time!");
  37.     rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  38.   }
  39.   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  40.  
  41.   pinMode(LED_BUILTIN, OUTPUT);
  42.   digitalWrite(LED_BUILTIN, LOW);
  43. }
  44.  
  45. void loop ()
  46. {
  47.   delay(1000);
  48.   now = rtc.now();
  49.   //showDate();
  50.   //showDay();
  51.   //showTime();
  52.   Serial.println(now.minute());
  53.  
  54.   if(now.minute() == 25){
  55.        lightLED();
  56.     }
  57.     else{
  58.           digitalWrite(LED_BUILTIN, LOW);
  59.       }
  60. }
  61.  
  62. void showDate()
  63. {
  64.   Serial.print(now.day());
  65.   Serial.print('/');
  66.   Serial.print(now.month());
  67.   Serial.print('/');
  68.   Serial.print(now.year());
  69. }
  70.  
  71. void showDay()
  72. {
  73.  
  74.   Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
  75. }
  76.  
  77. void showTime()
  78. {
  79.   Serial.print("Time:");
  80.   Serial.print(now.hour());
  81.   Serial.print(':');
  82.   Serial.print(now.minute());
  83.   Serial.print(':');
  84.   Serial.print(now.second());
  85.   Serial.print("    ");
  86. }
  87.  
  88. void lightLED(){
  89.   digitalWrite(LED_BUILTIN, HIGH);
  90.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top