Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include "RTClib.h"
- RTC_DS3231 rtc;
- char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
- void setup() {
- // put at the end of setup function:
- initRTC();
- }
- void loop() {
- DateTime now = rtc.now();
- // 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16
- if (now.hour() >= 8 && now.hour() <= 16) {
- }
- else {
- }
- }
- ////////////////////////////////////////////////
- void initRTC() {
- if (! rtc.begin()) {
- Serial.println("Couldn't find RTC");
- Serial.flush();
- while (1) delay(10);
- }
- if (rtc.lostPower()) {
- Serial.println("RTC lost power, let's set the time!");
- rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
- }
- }
- ////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement