#include <Wire.h>
#include <RTClib.h>
RTC_DS1307 Rtc;
int led1 = 2; // Replace with the actual pin connected to the relay module
void setup() {
Serial.begin(115200);
Wire.begin();
Rtc.begin();
pinMode(led1, OUTPUT);
digitalWrite(led1, LOW);
// Uncomment the next line if you want to set the RTC to the time at which the sketch was compiled
// Rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
void loop() {
DateTime now = Rtc.now();
// Check if it's time to turn on the street lights (6 PM to 6 AM)
if (now.hour() >= 18 || now.hour() < 6) {
digitalWrite(led1, HIGH); // Turn on street lights
} else {
digitalWrite(led1, LOW); // Turn off street lights
}
// Print the current time
Serial.print("Current time: ");
Serial.print(now.year());
Serial.print("-");
Serial.print(now.month());
Serial.print("-");
Serial.print(now.day());
Serial.print(" ");
Serial.print(now.hour());
Serial.print(":");
Serial.print(now.minute());
Serial.print(":");
Serial.print(now.second());
Serial.println();
delay(1000); // Update every second
}