0
lcd_key = read_LCD_buttons();
float temp = dht.readTemperature();
delay(1000);
// lcd.setCursor(0,0);

if(temp < 0) {
    lcd.print(temp);  
}

if(temp >= 0.00 || temp <= 5.00) {
    lcd.setCursor(0,6);
    lcd.print(temp);
    delay(100);  
}

Here I got simple code about reading temperature from DHT sensor and lcd but when I raise or lower the DHT's temperature the lcd's cursor always printing my data from 0,0.

I want that when the temperature between 0-5 celcius it shall write data on 0,6 in lcd screen but this code not working.

Thank you for answers.

1
  • review the setcutsor() command
    – jsotola
    Apr 28 '20 at 20:33
1

I have a feeling you may be using invalid coordinates.

0, 6 means Column 0, Row 6, but most LCDs don't have 6 rows. Instead I think you want 6, 0 for Column 6, row 0.

1

I guess it because you use

if(temp >= 0.00 || temp <= 5.00){ // writes over 0 OR under 5 which will always be true for all values measured

and not

if(temp >= 0.00 && temp <= 5.00){   // writes over 0 AND under 5 which you want
1
  • the logic error in the OP's code causes temp to always print at (0,6)
    – jsotola
    Apr 28 '20 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.