Thermostat LCD display doesn't turn on

Could someone explain to me why the LCD display doesn't turn on, here's a screenshot of the project, and the code of the project.

Here the code:

#include <LiquidCrystal.h>

#define LM35pin 0 // connect LM35 Vout pin to arduino analog pin 0
#define LM35ref 1 // connect 2x 1N1418 diodes between LM35 ground pin and ground
#define thermistor_pin 3

#define btnPin1 11
#define btnPin2 12

#define ledPin 8

#define LCD_RS 2
#define LCD_EN 3
#define LCD_D4 4
#define LCD_D5 5
#define LCD_D6 6
#define LCD_D7 7

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);

float myTemp = 26.0;

int btnState1 = 0;
int lastBtnState1 = 0;
int btnState2 = 0;
int lastBtnState2 = 0;

byte iconTermo[8] = {
  B00100,
  B01010,
  B01010,
  B01110,
  B01110,
  B11111,
  B11111,
  B01110
};

byte iconDegree[8] = {
  B01000,
  B10100,
  B01000,
  B00011,
  B00100,
  B00100,
  B00011,
  B00000
};

byte iconMan[8] = {
  B00100,
  B01010,
  B00100,
  B01110,
  B10101,
  B00100,
  B01010,
  B01010
};

void setup()
{
  lcd.createChar(0, iconTermo);
  lcd.createChar(1, iconDegree);
  lcd.createChar(2, iconMan);
  lcd.begin(16, 4);

  pinMode(btnPin1, INPUT);
  pinMode(btnPin2, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  // LM35
  float temp2 = readLM35(true); // true = temp in celsius, false = temp in fahrenheit

  lcd.setCursor(16, 0);
  lcd.write((byte) 0);
  lcd.print(temp2, 1);
  lcd.write((byte) 1);

  lcd.print("    ");

  // thermistor
  int sensorValue = analogRead(thermistor_pin);
  float temp3  = Thermistor(sensorValue)/2;
  float temp4 = round(temp3 * 2.0) / 2.0;

  lcd.write((byte) 0);
  lcd.print(temp4, 1);
  lcd.write((byte) 1);

  
  btnState1 = digitalRead(btnPin1);

  if (btnState1 != lastBtnState1)
  {
    if (btnState1 == HIGH)
    {
      // off => on
      myTemp++;
    }
  }
  lastBtnState1 = btnState1;

 
  btnState2 = digitalRead(btnPin2);

  if (btnState2 != lastBtnState2)
  {
    if (btnState2 == HIGH)
    {
      // off => on
      myTemp--;
    }
  }
  lastBtnState2 = btnState2;

  
  lcd.setCursor(16,1);
  lcd.write((byte) 2);
  lcd.print(myTemp,1);
  lcd.write((byte) 1);
  lcd.print("       ");

  if(myTemp<temp2)
  {
    // accendo la ventola
    lcd.print("ON ");
    digitalWrite(ledPin, HIGH); 
  }
  else
  {
    lcd.print("OFF");
    digitalWrite(ledPin, LOW);
  }

  delay(100);
}


float readLM35(boolean celsius)
{
  int analogVal = 0;
  for(int j = 0; j < 10; j++) // takes 10 samples to make sure we get a good value
  {
    analogVal += (analogRead(LM35pin) - analogRead(LM35ref)); // subtract Vout ADC reading from LM35 ground ADC reading
    delay(10);
  }

  float tempC = (5 * analogVal * 10) / 1023;

  if (celsius)
  {
    return tempC; // return temperature in degrees Celsius
  }
  else
  {
    return (tempC * 9 / 5) + 32; // return temperature in degrees Fahrenheit
  }
}

double Thermistor(int RawADC)
{
  double Temp;
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
  Temp = Temp - 273.15;            // Convert Kelvin to Celsius
  return Temp;
}

I think pin 4 of your LCD (the RS pin) should go to pin 12 of the UNO.

But also that 1k backlight resistor looks rather high; try 220.

Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

Still doesn't work, the RS pin is 2 of my LCD, not 4

RS typically goes to pin 12, What was your source?

Try my LCD circuit
LCD pin UNO/Nano pin
1 0V G
2 5V 5V
3 V0 10k Contrast preset
4 RS 12
5 RS G
6 Enable 11
11 D4 5
12 D5 4
13 D6 3
14 D7 2
15 Anod 220 ohm to backlight
16 Cath to backlight

@zkrard Your LCD connections are correct according to your code.

But there are some lines that are "wrong".

Line 79 lcd.setCursor(16, 0); Why starting position at the end of the line?
Try lcd.setCursor(0, 0);

Line 122 lcd.setCursor(16, 1); also why starting position at the end of the line?
Try lcd.setCursor(0, 1);

What do you imagine this line (77) is doing?
float temp2 = readLM35(true);

Simulation with modified lines 79 and 122.

Check that the power-rail on your breadboard have a connection cross the broad gap,
just left of the GND connection on the LCD.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.