Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- GND -> GND
- VCC -> 5V
- SDA -> 20SDA
- SCL -> 21SCL
- */
- #include <Wire.h>
- #include "RTClib.h"
- DateTime now;
- char daysOfTheWeek[7][12] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
- RTC_DS3231 rtc;
- void showDate(void);
- void showTime(void);
- void showDay(void);
- void setup ()
- {
- Serial.begin(9600);
- //delay(2000);
- if (! rtc.begin())
- {
- Serial.println("Couldn't find RTC Module");
- while (1);
- }
- if (rtc.lostPower())
- {
- Serial.println("RTC lost power, lets set the time!");
- rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
- }
- rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
- pinMode(LED_BUILTIN, OUTPUT);
- digitalWrite(LED_BUILTIN, LOW);
- }
- void loop ()
- {
- delay(1000);
- now = rtc.now();
- //showDate();
- //showDay();
- //showTime();
- Serial.println(now.minute());
- if(now.minute() == 25){
- lightLED();
- }
- else{
- digitalWrite(LED_BUILTIN, LOW);
- }
- }
- void showDate()
- {
- Serial.print(now.day());
- Serial.print('/');
- Serial.print(now.month());
- Serial.print('/');
- Serial.print(now.year());
- }
- void showDay()
- {
- Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
- }
- void showTime()
- {
- Serial.print("Time:");
- Serial.print(now.hour());
- Serial.print(':');
- Serial.print(now.minute());
- Serial.print(':');
- Serial.print(now.second());
- Serial.print(" ");
- }
- void lightLED(){
- digitalWrite(LED_BUILTIN, HIGH);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement