so first off im horrible at explaing myself
heres my thing
#include "RTClib.h"
#include <Wire.h>
#include <LiquidCrystal.h>
DS3231 rtc;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Pins /////////////////////////////////////////////
//water pump relay pin
#define waterpump 5
//Light 1 pin
#define light1 3
//Light 2 pin
#define light2 4
#define circ 2
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Misc /////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Water ///////////////////////////////////////
//amount of time water is on for; watering length
const int watertime = 5000;
//water pump time on first time
const int pumpOnHour1 = 23;
const int pumpOnMinute1 = 59;
const int pumpOnSecond1 = 1;
//water pump time on second time
const int pumpOnHour2 = 14;
const int pumpOnMinute2 = 22;
const int pumpOnSecond2 = 1;
//water pump time on third time
const int pumpOnHour3 = 14;
const int pumpOnMinute3 = 23;
const int pumpOnSecond3 = 1;
//water pump time on forth time
const int pumpOnHour4 = 14;
const int pumpOnMinute4 = 24;
const int pumpOnSecond4 = 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////lights/////////////////////////////////////
//Light 1
//on
const int light1OnHour = 12;
const int light1OnMinute = 1;
//off
const int light1OffHour = 24;
const int light1OffMinute = 1;
//Light 2
//on
const int light2OnHour = 12;
const int light2OnMinute = 6;
//off
const int light2OffHour = 24;
const int light2OffMinute = 6;
//////////////////////////////////////////////////////////////// other shit waiting to give me a headache///////////////////////////////////////////////////////////////////
/*Relay4
const int OnHour = ;
const int OnMinute = ;
const int OnSecond = ;
const int OffHour = ;
const int OffMinute = ;
const int OffSecond = ;
//Relay5
const int OnHour = ;
const int OnMinute = ;
const int OnSecond = ;
const int OffHour = ;
const int OffMinute = ;
const int OffSecond = ;
//Relay6
const int OnHour = ;
const int OnMinute = ;
const int OnSecond = ;
const int OffHour = ;
const int OffMinute = ;
const int OffSecond = ;
//Relay7
const int OnHour = ;
const int OnMinute = ;
const int OnSecond = ;
const int OffHour = ;
const int OffMinute = ;
const int OffSecond = ;
//Relay8
const int OnHour = ;
const int OnMinute = ;
const int OnSecond = ;
const int OffHour = ;
const int OffMinute = ;
const int OffSecond = ;
*/
void setup() {
Serial.begin(9600);
Wire.begin();
rtc.begin();
rtc.adjust(DateTime(__DATE__, __TIME__));
if (! rtc.isrunning()) {
Serial.println("RTC is NOT running!");
}
//set pins (outputs)
pinMode(waterpump, OUTPUT);
pinMode(light1, OUTPUT);
pinMode(light2, OUTPUT);
pinMode(circ, OUTPUT);
//set pins (inputs)
}
void loop() {
water();
lights();
circulation();
}
void water()
{
static unsigned long wateron = 0;
DateTime now = rtc.now();
// serial print out of time
char buf[100];
strncpy(buf, "DD.MM.YYYY hh:mm:ss\0", 100);
Serial.println(now.format(buf));
if ((now.hour() == pumpOnHour1 && now.minute() == pumpOnMinute1 && now.second() == pumpOnSecond1)
|| (now.hour() == pumpOnHour2 && now.minute() == pumpOnMinute2 && now.second() == pumpOnSecond2)
|| (now.hour() == pumpOnHour3 && now.minute() == pumpOnMinute3 && now.second() == pumpOnSecond3)
|| (now.hour() == pumpOnHour4 && now.minute() == pumpOnMinute4 && now.second() == pumpOnSecond4))
{
Serial.println("water pump is on");
digitalWrite(waterpump, HIGH);
wateron = millis();
}
if (digitalRead(waterpump) == HIGH)
{
if (millis() - wateron > watertime)
{
digitalWrite(waterpump, LOW);
Serial.println("water pump is off");
}
}
}
void lights()
{
DateTime now = rtc.now();
/////light 1//////////////
if (now.hour() == light1OnHour && now.minute() == light1OnMinute)
{ Serial.println("light 1 is on");
digitalWrite(light1, HIGH);
}
if (now.hour() == light1OffHour && now.minute() == light1OffMinute)
{ Serial.println("light 1 is off");
digitalWrite(light1, LOW);
}
////////////light2///////////
if (now.hour() == light2OnHour && now.minute() == light2OnMinute)
{ Serial.println("light 2 is on");
digitalWrite(light2, HIGH);
}
if (now.hour() == light2OffHour && now.minute() == light2OffMinute)
{ Serial.println("light 2 is off");
digitalWrite(light2, LOW);
}
}
void circulation()
{
DateTime now = rtc.now();
if (now.hour() == pumpOnHour1) && now.minute() == pumpOnMinute1)
{
digitalWrite(circ, HIGH);
}
if (now.hour() == pumpOffHour1 && now.minute() == pumpOffMinute1)
{
digitalWrite(circ, LOW);
}
}
in this spot
void circulation()
{
DateTime now = rtc.now();
if (now.hour() == pumpOnHour1) && now.minute() == pumpOnMinute1)
{
digitalWrite(circ, HIGH);
}
if (now.hour() == pumpOffHour1 && now.minute() == pumpOffMinute1)
{
digitalWrite(circ, LOW);
}
}
i want my circulation pump to turn on an hour before, and turn off 30 min after my water pump does
what i cant figure out is how to add a +1 or -30 into there respected place,
so like
if
(now.hour() == pumpOnHour1 -1)
{digitalWrite(circ, HIGH);
where, how and WHY do i put my time alteration ?