I need the 2nd row to clear every time for the clock, not the 1st row.
Top row I have the temperature reading
Bottom row I have the clock reading.
When I add "lcd.clear();" on the void digitalClockDisplay() section at the bottom, it clears the top row instead, which I don't want.
How do I fix this issue?
#include <LiquidCrystal440.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <DateTime.h>
#include <DateTimeStrings.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 = 31; // heater LED indicator
void setup()
{ DateTime.sync(DateTime.makeTime(50, 59, 23, 16, 10, 2010));
lcd.begin(16,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);
}
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);
}
}
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
lcd.setCursor(0,0);
lcd.print(" Temp:");
lcd.print(DallasTemperature::toFahrenheit(tempC));
lcd.print((char)223);
lcd.print((char)70);
if (DallasTemperature::toFahrenheit(tempC) < 75.00)
heater = 1;
else
heater = 0;
}
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.print(" ");
if(DateTime.Hour <10)
lcd.setCursor(5,1);
lcd.setCursor(4,1);
// digital clock display of current time
lcd.print(DateTime.Hour,DEC);
printDigits(DateTime.Minute);
printDigits(DateTime.Second);
}