Here is the whole code, we thought having only a portion might make it easier to read.
#include <DateTimeStrings.h>
#include <OneWire.h>
#include <LiquidCrystal440.h>
#include <DateTime.h>
#include <DallasTemperature.h>
#define dt_SHORT_DAY_STRINGS
#define dt_SHORT_MONTH_STRINGS
#define ONE_WIRE_BUS 9
OneWire oneWire(ONE_WIRE_BUS);
int heater;
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = { 0x10, 0x37, 0xBC, 0x1E, 0x02, 0x08, 0x00, 0xE9 };
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int LED1 = 10; // heater pin location
int LED2 = 25; // heater LED indicator
const int waterchangebutton = 51;
const int buttonPin1 = 51; // the number of the pushbutton pin
const int buttonPin2 = 50;
const int buttonPin3 = 49;
const int buttonPin4 = 48;
const int ledPin1 = 35; // the number of the LED pin
const int ledPin2 = 34;
const int ledPin3 = 33; // the number of the LED pin
const int ledPin4 = 32;
const int waterchangePin = 35; // the number of the Equipment pin
const int drainsolenoidPin = 34;
const int addwaterPin = 33;
const int addwaterPumpPin = 32;
const int feederPin = 31;
// initialize fitler pin as output
const int filter = 31;
unsigned long off_time1;
unsigned long off_time2;
unsigned long off_time3;
unsigned long off_time4;
unsigned long off_timeDrainWater;
unsigned long off_timeAddWater;
boolean ledState1 = false;
boolean ledState2 = false;
boolean ledState3 = false;
boolean ledState4 = false;
boolean filterState = true;
boolean waterchangeState=false;
boolean drainsolenoidState=false;
boolean addwaterState=false;
boolean addwaterPumpState = false;
int waterchangeButtonState = 0; // variable for reading the pushbutton status
int buttonState1 = 0; // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0; // variable for reading the pushbutton status
int buttonState4 = 0;
void setup()
{ DateTime.sync(DateTime.makeTime(50, 59, 7, 16, 10, 2010));
lcd.begin(8,2);
pinMode(LED1, OUTPUT); // heater pin location
pinMode(LED2, OUTPUT); // heater LED indicator
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(insideThermometer, 10);
pinMode(addwaterPin, OUTPUT);
pinMode(waterchangePin, OUTPUT);
pinMode(drainsolenoidPin, OUTPUT);
pinMode(addwaterPumpPin, OUTPUT);
pinMode(feederPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(waterchangebutton, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
digitalWrite(waterchangePin, LOW);
digitalWrite(drainsolenoidPin, LOW);
digitalWrite(addwaterPin, LOW);
digitalWrite(addwaterPumpPin, LOW);
digitalWrite(feederPin, LOW);
pinMode(filter, OUTPUT);
digitalWrite(filter, HIGH);
pinMode(filter, OUTPUT);
digitalWrite(filter, HIGH);
}
void loop()
{
if(DateTime.available()) {
unsigned long prevtime = DateTime.now();
while( prevtime == DateTime.now() ) // wait for the second to rollover
;
DateTime.available(); //refresh the Date and time properties
digitalClockDisplay( ); // update digital clock
}
sensors.requestTemperatures();
printTemperature(insideThermometer);
if (heater ==1){
digitalWrite(LED1, HIGH); // Heater pin
digitalWrite(LED2, HIGH); // Heater LED indicator
} else {
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
}
if ((waterchangeState) && (millis()>=off_time1)) /* is it on and is it later or equal to off_time */
{
digitalWrite(waterchangePin,LOW);
waterchangeState = false;
//filterState = true;
if((drainsolenoidState) && (millis()>=off_timeDrainWater))
{
digitalWrite(drainsolenoidPin, LOW);
digitalWrite(addwaterPin, HIGH);
addwaterState = true;
digitalWrite(addwaterPumpPin, HIGH);
addwaterPumpState = true;
off_timeAddWater = millis() + 3000;
}
//filterState = true;
//digitalWrite(filter, HIGH);
}
else if ((!waterchangeState) && (filterState)) /* is it off? */
{
waterchangeButtonState = digitalRead(waterchangebutton);
if(waterchangeButtonState == HIGH)
{
digitalWrite(filter, LOW);
filterState = false;
digitalWrite(waterchangePin, HIGH);
digitalWrite(drainsolenoidPin, HIGH);
drainsolenoidState = true;
off_timeDrainWater = millis() + 3000;
waterchangeState = true;
off_time1 = millis() + 3000;
}
}
if((addwaterPumpState) && (millis()>=off_timeAddWater))
{
digitalWrite(addwaterPumpPin, LOW);
addwaterPumpState = false;
digitalWrite(addwaterPin, LOW);
addwaterState = false;
filterState = true;
digitalWrite(filter, HIGH);
}
if ((ledState2) && (millis()>=off_time2)) /* is it on and is it later or equal to off_time */
{
digitalWrite(ledPin2,LOW);
ledState2 = false;
}
else if (!ledState2) /* is it off? */
{
buttonState2 = digitalRead(buttonPin2);
if(buttonState2 == HIGH)
{
digitalWrite(ledPin2, HIGH);
ledState2 = true;
off_time2 = millis() + 5000;
}
}
if ((ledState3) && (millis()>=off_time3)) /* is it on and is it later or equal to off_time */
{
digitalWrite(ledPin3,LOW);
digitalWrite(ledPin4,LOW);
ledState4 = false;
ledState3 = false;
}
else if (!ledState3) /* is it off? */
{
buttonState3 = digitalRead(buttonPin3);
if(buttonState3 == HIGH)
{
digitalWrite(ledPin3, HIGH);
ledState3 = true;
digitalWrite(ledPin4, HIGH);
ledState4 = true;
off_time3 = millis() + 7000;
}
}
if(DateTime.Hour==10 && DateTime.Minute==0)
{ledState2 = true;
digitalWrite(ledPin2, HIGH);
}
if(DateTime.Hour==10 && DateTime.Minute ==1)
{ledState2 = false;
digitalWrite(ledPin2, LOW);
}
}
void printDigits(byte digits){
// utility function for digital clock display: prints preceding colon and leading 0
lcd.print(":");
if(digits < 10)
lcd.print('0');
lcd.print(digits,DEC);
}
void digitalClockDisplay(){
lcd.setCursor(7,0);
lcd.print("");
//lcd.print(" ");
if(DateTime.Hour <10)
lcd.setCursor(7,0);
// digital clock display of current time
lcd.print(DateTime.Hour,DEC);
printDigits(DateTime.Minute);
printDigits(DateTime.Second);
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
lcd.setCursor(0,0);
lcd.print("");
lcd.print(DallasTemperature::toFahrenheit(tempC));
lcd.print((char)223);
if (DallasTemperature::toFahrenheit(tempC) < 75.00)
heater = 1;
else
heater = 0;
}
This is the unmodified code, we want to add the float sensor code in the first post to the above code. Also I will have the waterchange function be dependent on the float sensor as well.