I can not get it to write the pump state to the LCD.
Code from line 79 should display the pump state.
// Starting the pump sketch using seconds
#include <TimeLib.h>
#include <TimeAlarms.h>
#include <Wire.h> //Arduino library
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
// Variables will change :
int RunningSeks; //Storing the Running Millis to seconds
int ReduceRunningBy = 0; // will store last time cycle was reset
int RunningLoop; // will store where in the loop we are
// Constants that won't change :
int OnInterval = 150; // interval at which Pump is on 150
int LoopDuration = 3600; // interval at which Cycle will reset
const int PumpRelayPin = 7; // Pin to connect Relay to ORANGE wire
const int LightPin = 8; //Wire to Light Relay YELLOW wire
void setup()
{
Serial.begin(9600); // initialize serial communication:
pinMode (LightPin , OUTPUT);
pinMode (PumpRelayPin , OUTPUT);
digitalWrite (LightPin , HIGH);
digitalWrite (PumpRelayPin , HIGH);
setTime(16,57,0,2,10,19); // set time to Saturday 9:06:00am Jan 19 2019
// *********************Defining the ALARMS*************************
// Alarm.alarmRepeat(20,45,0, LightsOn); // every day
// Alarm.alarmRepeat(4,45,0,LightsOff); // every day
// pinMode (LightPin, OUTPUT);
lcd.init(); // initialize the lcd
lcd.backlight();
} //end setup
void loop()
{
RunningSeks = (millis()/1000);
RunningLoop = (RunningSeks - ReduceRunningBy);
Serial.println(RunningLoop);
lcd.setCursor(0,0); //Firt set the cursor position, Second digit is always the line
lcd.print("Loop =");
lcd.setCursor(7,0); //Firt set the cursor position, Second digit is always the line
lcd.print(RunningLoop);
lcd.setCursor(12,0); //Firt set the cursor position, Second digit is always the line
lcd.print("Sec");
if(RunningLoop <= OnInterval)
{
digitalWrite(PumpRelayPin, LOW);
Serial.print("E & F Pump in ON ");
//Serial.println(RunningLoop);
}
if((RunningLoop >= 170) && (RunningLoop < 770)) //turn other pump on 170 & 770
{
Serial.println("Alarm: - Floating Raft Pump ON");
digitalWrite(LightPin, LOW);
}
if(RunningLoop >= 771) // 771
{
Serial.println("Alarm: - Floating Raft Pump OFF");
digitalWrite(LightPin, HIGH);
}
if((RunningLoop > OnInterval)&&(RunningLoop <= LoopDuration))
{
digitalWrite(PumpRelayPin, HIGH);
Serial.print("E & F Pump in OFF ");
Serial.println(RunningLoop);
}
if(RunningLoop > LoopDuration)
{
Serial.print("***********************************Reset Loop ********************************************* ");
Serial.println(RunningLoop);
ReduceRunningBy = RunningSeks;
}
digitalRead(PumpRelayPin);
if (PumpRelayPin == LOW)
{
lcd.setCursor(0,1);
lcd.print("E&F On");
}
digitalRead(PumpRelayPin);
if (PumpRelayPin == HIGH)
{
lcd.setCursor(0,1);
lcd.print("E&F OFF");
}
digitalRead(LightPin);
if (LightPin == LOW)
{
lcd.setCursor(0,10);
lcd.print("F/Raft On");
}
digitalRead(LightPin);
if (LightPin == HIGH)
{
lcd.setCursor(0,10);
lcd.print("F/Raft OFF");
}
} //*********************** End loop
void LightsOn() // functions to be called when an alarm triggers:
{
Serial.println("Alarm: - turn lights ON");
digitalWrite(LightPin, LOW);
}
void LightsOff()
{
Serial.println("Alarm: - turn lights OFF");
digitalWrite(LightPin, HIGH);
}
void digitalClockDisplay() {
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits) {
Serial.print(":");
if (digits < 10)
Serial.print('0');
Serial.print(digits);
}