#include <Wire.h>
#include <RTClib.h>
const int ledPin = 13; // LED connected to digital pin 13
const int buttonPin = 2; // Push button connected to digital pin 2
RTC_DS1307 rtc;
void setup() {
pinMode(ledPin, OUTPUT); // Initialize the LED pin as an output
pinMode(buttonPin, INPUT); // Initialize the button pin as an input
rtc.begin(); // Initialize RTC
if (!rtc.isrunning()) {
Serial.println("RTC is NOT running!");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // Set the RTC to the current date & time
}
}
void loop() {
DateTime now = rtc.now(); // Get the current time from the RTC
// Check if the time is 11:00:00
if (now.hour() == 14 && now.minute() == 3 && now.second() == 0) {
digitalWrite(ledPin, HIGH); // Turn on the LED
} else {
digitalWrite(ledPin, LOW); // Turn off the LED
}
// Check if the button is pressed
if (digitalRead(buttonPin) == HIGH) {
digitalWrite(ledPin, LOW); // Turn off the LED when the button is pressed
delay(1000); // Debouncing delay
}
delay(1000); // Update every second
}