My lcd is not showing text just showing boxes

I don’t know what’s going on but my lcd doesn’t show text but only rectangular boxes. I can change this and make it disappear.

#include <LiquidCrystal.h> // LCD Library
#include "HX711.h" // Load cell library

#define DOUT 5 // Arduino Pin connection data
#define CLK 4 // Arduino Pin connection data
#define SW2 2 // Right switch (unit swap)
#define SW1 3 // Left switch (tare)

HX711 loadCell; // Creates the Scale Object
long int rawValue, tareValue; // Long variables
double calibrationFactor = 0.002230622; // [grams/ADC value]
const int rs = 8, en = 6, d4 = 7, d5 = 11, d6 = 12, d7 = 13; // Pins for the LCD
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

const int MAX_UNITS = 4; // Update this value as you add more units
int selectedUnit = 1; // Default unit (Grams)
const double MAX_WEIGHT = 5000.0; // Load cell max capacity relative to grams

void setup() {
    pinMode(SW1, INPUT_PULLUP);
    pinMode(SW2, INPUT_PULLUP);

    lcd.begin(16, 2);
    lcd.setCursor(3, 0);
    lcd.print("Warming up");
    delay(5000);
    lcd.clear();
    lcd.print("...Almost there");
    delay(5000);

    Serial.begin(9600);
    loadCell.begin(DOUT, CLK, 128);

    lcd.clear();
    lcd.setCursor(2, 0);
    lcd.print("Please clear");
    lcd.setCursor(3, 1);
    lcd.print("load tray");
    delay(5000);
    lcd.clear();
    lcd.setCursor(3, 0);
    lcd.print("Commencing");
    lcd.setCursor(2, 1);
    lcd.print("TARE function");
    tareValue = loadCell.read_average(150);
    lcd.clear();
    lcd.setCursor(1, 0);
    lcd.print("TARE function");
    lcd.setCursor(3, 1);
    lcd.print("complete");
    delay(2000);
    lcd.clear();
    lcd.setCursor(4, 0);
    lcd.print("All set!");
}

void loop() {
    static unsigned long lastSW2Press = 0;
    static unsigned long lastSW1Press = 0;
    const unsigned long debounceDelay = 100;

    bool sw2State = digitalRead(SW2);
    bool sw1State = digitalRead(SW1);

    if (sw2State == LOW && millis() - lastSW2Press > debounceDelay) {
        selectedUnit = (selectedUnit % MAX_UNITS) + 1;
        lastSW2Press = millis();
    }

    if (sw1State == LOW && millis() - lastSW1Press > debounceDelay) {
        lcd.clear();
        lcd.setCursor(3, 0);
        lcd.print("Commencing");
        lcd.setCursor(2, 1);
        lcd.print("TARE function");
        tareValue = loadCell.read_average(150);
        lcd.clear();
        lcd.setCursor(1, 0);
        lcd.print("TARE function");
        lcd.setCursor(3, 1);
        lcd.print("complete");
        delay(2000);
        lcd.clear();
        lastSW1Press = millis();
    }

    rawValue = loadCell.read_average(40) - tareValue;

    if (abs(rawValue) < 150) {
        rawValue = 0;
    }

    double Grams = rawValue * calibrationFactor;
    double Kilograms = Grams / 1000.0;
    double Pounds = Grams * 0.00220462;
    double Ounces = Grams * 0.035274;

    char buffer[16]; // Buffer for formatted text
    lcd.setCursor(0, 1);
    lcd.print("TARE");
    lcd.setCursor(11, 1);
    lcd.print("units");

    lcd.setCursor(0, 0);
    if (Grams > MAX_WEIGHT) {
        lcd.print("Max weight!");
    } else {
        switch (selectedUnit) {
        case 1:
            snprintf(buffer, 16, "%.2f Grams", Grams);
            break;
        case 2:
            snprintf(buffer, 16, "%.2f Kg", Kilograms);
            break;
        case 3:
            snprintf(buffer, 16, "%.2f lbs", Pounds);
            break;
        case 4:
            snprintf(buffer, 16, "%.2f Oz", Ounces);
            break;
        }
        lcd.print(buffer);
    }
}
```
 



Here is my code and my wiring.
![image|375x500](upload://igZ6bSWhM9rtrw4yDp9sNtBpApK.jpeg)

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

It's hard to tell from that dark and obscured photo, but it doesn't appear to me that you have any wires hooked up to the pins that are specified in the code. That being the case, it's no wonder the LCD doesn't work.

Show us a clear, well lit, in focus, unobscured picture of your wiring. One in which we can see where all the wires connect.



Hope these two photos are better

From that second photograph in post #4, it looks as though you have a serial UART connection to the LCD.

I think that this means that the lines:

const int rs = 8, en = 6, d4 = 7, d5 = 11, d6 = 12, d7 = 13; // Pins for the LCD
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

are unnecessary.

However you have the TX pin of the LCD connected to the TX pin of the Arduino, and the RX pin of the LCD connected to the RX pin of the Arduino.
These need to be crossed over, so that TX goes to RX, and RX to TX.

You might also need to use a different library for a serial LCD.

Did the LCD come with any instructions?

I am struggling to understand what is going on here? Is your code running on the Elegoo (UNO) board?

That board seems to have only power and Rx/Tx pins connected to the board with the LCD screen. There is nothing actually driving the LCD. It looks like there should be a programmed Atmel 328p (or at least some kind of MCU) chip plugged into that socket on the LCD board.

The blocks may be just down to the contrast setting which looks like it is controlled by the black pot marked 'LCD contrast'. You will probably find they will disappear when you adjust that control. I agree with van_der_drecken. The LCD is not being driven so it is not displaying anything.

It’s the lcd from the arduino uno kit

I can adjust the contrast it just that nothing is being shown either way

Which kit? Can you post a link?

Are you reading any of these posts?

Hi yes I am so far still the same issue

You should acknowledge or answer the posts.

I currently am

I don’t understand what you mean by the lcd not being driven ?

Ok, and is that what you are doing?

BTW, could you help us out by editing your opening post and ensuring that all of the code is within the CODE tags. Makes is much easier to read and to provide help.
Thanks.

After programming with arduino IDE I’m supposed to remove the chip from
the arduino and add it to the pcb

I posted a link on where it comes from. That’s the only information I have . It’s also 16x2 LCD

I’m supposed to make sure the text displays on the lcd display before removing the chip, but nothing shows

The text won't show until you plug the chip into the LCD board. When you do so, be careful to make sure that it is the correct way around.