Diablillowilly:
1-Why is my code not working?
Because you are not wiggling the PCF8574 pins correctly to control the LCD.
You appear to be sending an 8 bit pattern in attempt to set all 8 LCD dbx pins. However you can't do that.
The PCF8574 only has an 8 bit output port so when hooked to an LCD, it can only control 4 data pins and up to 4 other signals. You have EN and RS hooked up.
You have to send each nibble separately. The tutorial you linked to talks about this. So does the data sheet.
But before you can talk to the LCD in 4 bit mode you must put the LCD in to 4 bit mode.
There is a very specific sequence of commands that must be sent to the LCD to reliably get the LCD into 4 bit mode that must be done first.
In order to send something/anything to the LCD, you must wiggle the E signal.
How that works for a write (which is sending data or commands) is documented in the datasheet on page 7.
The summary is you must set up the RS signal and the 4 data bits to what you want, then raise EN, then Lower it. It is the lowering of EN that sends the 4 bits to the LCD.
If you look closely at the signals on page 7 you see that RS must be stable when EN is raised (tAS) is zero, and the data signals can be set at any time but must be stable 40ns (tDSW) before lowering EN and then remain stable for 10ns (tH) after EN is lowered.
It takes multiple byte transfers to the PCF8574 to do this.
This chipset is signal & command compatible with the hd44780 chip and I think the information in the hitachi hd44780 datasheet is a bit better and more detailed about 4 bit mode and its initialization than what I see in this datasheet.
Although the low level timing for the hd44780 is a bit different. For example it wants 40ns for tAs vs this chip says tAS can be zero. However, from what I've seen zero tAS works on the PCF8574 as well.
Is there any good tutorial to learn how to use lcds at this level?
Not that I know of off the top of my head but the Internet is full of stuff. Try doing some googling.
You may want to look at an Arduino library that actually works doing this.
Have a look this library. It is available in the Arduino library manager:
I get lost and dont fully understand the datasheet
That may be an issue as working at this level requires manipulating actual h/w signals and the description of how the h/w works and the required timing is the datasheet.
If you are just wanting to use the LCD, and not write you own code (which is a lot of work),
then I'd recommend wiring it up a bit differently and using an existing working library.
And then either using the LiquidCrystal_I2C library or my hd44780 library with the hd44780_I2Cexp i/o class.
To use LiquidCrystal_I2C library you must wired it up like this:
LCD pcf8574 output port pin
DB7 P7
DB6 P6
DB5 P5
DB4 P4
P3 (optional backlight circuit control)
EN P2
RW P1
RS P0
The hd44780 library can work with that pin mapping as well.
BTW, you can buy pre-made i2c backpacks for these types of LCDs which include backlight control for less than $1 USD shipped to your door.
--- bill