So i have two messages on the lcd working fine. When i try to add a third message it does not appear to display.
I have attached the full code below but here are the relevant lines.
these are declared before setup:
//set the delay between the LCD display setting using millis (not the delay function)
unsigned long switchMillis = 0;
unsigned long interval = 5000; //5 seconds for each lcd screen
byte count = 0;
boolean firstScreenFlag = false;
boolean secondScreenFlag = false;
boolean thirdScreenFlag = false;
in setup the interior light function:
// turn on interior lights at dusk and turn off after door shuts
void doCoopInteriorLightDusk() {
if ((unsigned long)(millis() - lastTwilightTime) > TwilightDelay) { // delay 5 mins
lastTwilightTime = millis();
doReadPhotoCell();
bottomSwitchPinVal = digitalRead(bottomSwitchPin);
if (bottomSwitchPinVal == 1) { // if bottom reed switch circuit is open (door is open)
if (photocellReading >= 200) { // if it's twilight
if (photocellReading <= 350) {
digitalWrite (relayInteriorLedStrip, LOW); // turn on interior light relay
if (SerialDisplay) {
//Serial.println(" Interior Light: On");
}
}
}
}
else if (bottomSwitchPinVal == 0) { // if bottom reed switch circuit is closed (door is closed)
digitalWrite (relayInteriorLedStrip, HIGH); // turn off interior light relay
if (SerialDisplay) {
//Serial.println(" Interior Light: Off");
}
}
}
}
the lcd message functions:
// lcd screen displays
void doLcdMsg1() {
float temperature = getTemp(); // create temperature variable
pinMode(backLight, OUTPUT); // backlight pin set as output
digitalWrite(backLight, HIGH); // backlight on
lcd.begin(16, 2); // columns, rows
lcd.clear(); // start with blank screen
lcd.setCursor(0, 0); // set cursor to column 0, row 0
lcd.print("Coop Temp:"); // show "Temp"
lcd.print (temperature) ; // show temperature of interior coop
lcd.print("C"); // show "C"
lcd.setCursor(0, 1); // set cursor to column 0, row 1
lcd.print("Coop Door:"); // show "Coop Door"
if (bottomSwitchPinVal == 0) { // if coop door bottom switch is closed
lcd.print("Closed"); // display "Closed"
}
else {
lcd.print("Open"); // if coop door bottom switch is open display "Open"
}
}
void doLcdMsg2() {
lcd.clear(); // clear the screen
if (digitalRead(relayFan) == LOW) { //relayFan set to LOW as Songle Relay is on with Gnd Voltage
lcd.print("Cooling Fan: ON");
} //display that Cooling fan is on or off
else {
lcd.print("Cooling Fan: OFF");
}
lcd.setCursor(0, 1);
if (digitalRead(relayHeat) == LOW) { //relayHeater set to LOW as Songle Relay is on with Gnd Voltage
lcd.print("Coop Heater: ON");
} //display that Cooling fan is on or off
else {
lcd.print("Coop Heater: OFF");
}
}
void doLcdMsg3() {
lcd.clear(); // clear the screen
if (digitalRead(relayInteriorLedStrip) == HIGH) {
lcd.print("Lighting : OFF");
} //display if interior lighting is on or off
else {
lcd.print("Lighting : ON");
}
lcd.setCursor(0, 1);
lcd.print("Happy Chickens"); //display the happy message
}
and finally the loop:
void loop() {
doReadPhotoCell();
doCoopHVAC();
doCoopDoor();
doCoopDoorLed();
doCoopInteriorLightDusk();
// Delays for the LCD screen messages
if (millis() - switchMillis > interval)
{
count++;
if (count == 1)
firstScreenFlag = true;
if (count == 2)
{
secondScreenFlag = true;
count = 0;
}
if (count == 3)
{
thirdScreenFlag = true;
count = 0;
}
switchMillis += interval; //millis();
}
if (firstScreenFlag)
{
doLcdMsg1();
firstScreenFlag = false;
}
if (secondScreenFlag)
{
doLcdMsg2();
secondScreenFlag = false;
}
if (thirdScreenFlag)
{
doLcdMsg3();
thirdScreenFlag = false;
}
}
the first two messages display fine but doLcdMsg3(); doesn't display at all?
can anyone tell me why?
chicken_coop_auto.ino.ino (19.4 KB)