Since it’s the only thing in the first post, I figured it was worth posting PROPERLY in </> code tags !
//DS1307 - Version: Latest
// ADS1147 - Version: Latest
/*
DS1307 RTC (Real-Time-Clock) Example
Uno A4 (SDA), A5 (SCL)
Mega 20 (SDA), 21 (SCL)
Leonardo 2 (SDA), 3 (SCL)
*/
#include <Wire.h>
#include <DS1307.h>
#define RELAY1 7 //Defining the pin 7 of the Arduino for the 4 relay module
#define RELAY4 4 //Defining the pin 4 of the Arduino for the 4 relay module
DS1307 rtc;
// ———————————-
void setup()
{
pinMode(RELAY1, OUTPUT); //Defining the pin 7 of the Arduino as output
pinMode(RELAY4, OUTPUT); //Defining the pin 4 of the Arduino as output
/*init Serial port*/
Serial.begin(9600);
/*while(!Serial); wait for serial port to connect - needed for Leonardo only*/
/*init RTC*/
Serial.println("Init RTC...");
/*only set the date+time one time*/
//rtc.set(10, 23, 13, 22, 4, 2018); /*08:00:00 24.12.2014 //sec, min, hour, day, month, year*/
/*stop/pause RTC*/
// rtc.stop();
/*start RTC*/
rtc.start();
}
// ———————————-
void loop()
{
uint8_t sec, min, hour, day, month;
uint16_t year;
/*get time from RTC*/
rtc.get(&sec, &min, &hour, &day, &month, &year);
if(hour%2 == 0)
{
if(min>1 && min<6)
{
digitalWrite(RELAY1,LOW); // This will Turn ON the relay 1
digitalWrite(RELAY4,LOW); // This will Turn ON the relay4
}
else
{
digitalWrite(RELAY1,HIGH); // This will Turn the Relay Off
digitalWrite(RELAY4,HIGH); // This will Turn the Relay Off
}
}
else
{
digitalWrite(RELAY1,HIGH); // This will Turn the Relay Off
digitalWrite(RELAY4,HIGH); // This will Turn the Relay Off
}
/*serial output*/
Serial.print("\nTime: ");
Serial.print(hour, DEC);
Serial.print(":");
Serial.print(min, DEC);
Serial.print(":");
Serial.print(sec, DEC);
Serial.print("\nDate: ");
Serial.print(day, DEC);
Serial.print(".");
Serial.print(month, DEC);
Serial.print(".");
Serial.print(year, DEC);
/*wait a second*/
//delay(1000);
}