LCD Displaying random characters

My LCD is displaying random characters instead of letters. I attached my code.

Unless your code is too large to post, please post I as instructed in the "how to use this forum-please read" stickies. A photo of the LCD display would help, too.

second picture

What does the display show when you load and run the Hello World example from the LiquidCrystal library?

This is what it shows when I try the hello world code from the LiquidCrystal library

I tried your code with my Uno and an I2C LCD and the display reads fine, so your code works. The problem could be with the constructor for the lcd object or the actual hardware.

I have the same backpack, as near as I can tell by the first image, so the constructor should be right.

That points to a hardware problem. Carefully examine the solder joints on the pins that connect the backpack to the LCD for bridges and quality. Carefully inspect the soldering of the I2C expander chip for solder bridges between pins.

With very few exceptions, what you are seeing is the result of either connection issues between the PCF8574 and the LCD or from telling the library the incorrect pin mappings which are represented by the numbers in the constructor.

I'd recommend using my hd44780 library. The hd44780_I2Cexp i/o class is for backpacks like that.
Not only is it faster than the library you are using but it also has many additional features like it auto detects the i2c address and pin mappings.
It also includes a diagnostic sketch, I2CexpDiag to verify that the h/w and library are working properly.
It is available in the IDE library manager for easy installation.
You can read more about it on the github project page here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
or in the wiki.

--- bill

bperrybap:
With very few exceptions, what you are seeing is the result of either connection issues between the PCF8574 and the LCD or from telling the library the incorrect pin mappings which are represented by the numbers in the constructor.

I'd recommend using my hd44780 library. The hd44780_I2Cexp i/o class is for backpacks like that.
Not only is it faster than the library you are using but it also has many additional features like it auto detects the i2c address and pin mappings.
It also includes a diagnostic sketch, I2CexpDiag to verify that the h/w and library are working properly.
It is available in the IDE library manager for easy installation.
You can read more about it on the github project page here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
or in the wiki.

--- bill

I do really like using the library you suggested, and will be from now on, however this didnt fix the issue so
I think I just have a faulty board and have ordered another one to arrive in a couple days. Thanks!

If you run the diagnostic ( I2CexpDiag) and post the results, bperrybap may be able to tell what is wrong or at least where to look.

It is pretty rare for the backpack to be faulty. I think over a period of several years from forum posts I've seen maybe 3-4 of them.
And in those cases, all but one had bad solder connections on the PCF8574 chip.
What is much more common, and I have seen dozens of these cases, is that the solder connections on the backpack to the LCD have issues.
Either poor solder connections or pins shorted together.

--- bill

bperrybap:
It is pretty rare for the backpack to be faulty. I think over a period of several years from forum posts I've seen maybe 3-4 of them.
And in those cases, all but one had bad solder connections on the PCF8574 chip.
What is much more common, and I have seen dozens of these cases, is that the solder connections on the backpack to the LCD have issues.
Either poor solder connections or pins shorted together.

--- bill

Im not exactly sure what was wrong with my lcd, but after ordering a new one all is well! So my screen was just faulty. Thanks everyone for your help!

odcarder:
... after ordering a new one all is well! So my screen was just faulty. Thanks everyone for your help!

Having a fault device is an assumption that may be incorrect.
I'm assuming you never ran the hd44780 diagnostic sketch to test the device.

--- bill