LCD screen doesn't display

Despite the correct connection and programming of the screen, it only displays a black grid.
Here's code:

#include <LiquidCrystal.h>
#include <DHT.h>
#include <Adafruit_Sensor.h>

#define DHTPIN 2
#define DHTTYPE DHT11

const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

DHT dht(DHTPIN, DHTTYPE);

byte termometr[8] = {
  0b00100,
  0b00110,
  0b00100,
  0b00110,
  0b00100,
  0b01110,
  0b01110,
  0b00000
};

byte kropla[8] = {
  0b00100,
  0b00100,
  0b01110,
  0b01110,
  0b10111,
  0b10111,
  0b01110,
  0b00000
};

byte stopnie[8] = {
  0b00010,
  0b00101,
  0b00010,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};

void setup() {
  lcd.begin(16, 2);
  lcd.print("Czekaj...");

  lcd.createChar(0, termometr);
  lcd.createChar(1, kropla);
  lcd.createChar(2, stopnie);

  dht.begin();
  Serial.begin(9600);
}

void loop() {
  delay(2000);
  float temp = dht.readTemperature();
  float wilg = dht.readHumidity();

  if (isnan(temp) || isnan(wilg)) {
    lcd.home();
    lcd.print("Blad odczytu");
    Serial.println("Blad odczytu");
    return;
  }

  lcd.home();
  lcd.write((byte)0);
  lcd.print(" ");
  lcd.print(temp);
  lcd.print(" ");
  lcd.write((byte)2);
  lcd.print("C");
  lcd.setCursor(0, 1);
  lcd.write((byte)1);
  lcd.print(" ");
  lcd.print(wilg);
  lcd.print("  %");

  Serial.print("Temperatura: ");
  Serial.print(temp);
  Serial.print(" C, Wilgotnosc: ");
  Serial.print(wilg);
  Serial.println(" %");
}

show

Does it properly display in the serial monitor?
Did you try adjusting the potentiometer connected to the LCD VO pin ?

Yes

Hi @tomkopc,

your sketch works properly, see here:

I suggest that you carefully check the wiring of the LCD, especially that the background illumination is connected (Backlight anode = A)!

You can check here

życzę Ci sukcesu!

There are several libraries with the same name but do not all work alike. A code that you randomly downloaded may not work with the version that you have installed.

For best results, only trust the example code that comes with the installed library.

Avoid the confusion and install the hd44780 library. That is the best LCD library that I have come across. It has been actively maintained and the author is a frequent visitor to the display section. Install through the IDE library manager.

I dit that, but still doesn't work

That's a pity ... You should follow @groundFungus' suggestion then!

Always Show us a good image of your ‘actual’ wiring.

Does your LCD have a backlight? Did you properly connect A and K on the LCD?

We need more information from you so we can stop guessing. A schematic and some pics would be helpful.

Deleted

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