1602 LCD using I2C Adapter
Hardware
All of these 1602, 2002, 2004 LCD modules use the same HD44780 controller chip.
Download the documentation for it: https://www.sparkfun.com/datasheets/LCD/HD44780.pdf
Here's a schematic showing how the PCF8574 connects to the LCD:
https://www.electrodragon.com/w/File:1602_IIC_schematic_R2.png
Basically, via the I2C bus and the I2C expander, you are bit-banging commands & data into the display's parallel interface, using its 4-bit bus interface (4 of the bus pins aren't used).
Software
Using the library manager, install the LiquidCrystal library
Find the LiquidCrystal library inside your Arduino/libraries folder, and then open examples/HelloWorld_i2c\HelloWorld_i2c.ino sketch. Give this sketch a try. Run i2c_scanner to find your device's I2C address. Make sure the code is using your device's address! My I2C adapter board has its pins wired a little differently than the "default" Here's what I use: --- From HelloWorld_i2c.ino sketch --- //LiquidCrystal_I2C lcd(0x38); // Set the LCD I2C address //LiquidCrystal_I2C lcd(0x27); // Use I2C address 0x27 instead //LiquidCrystal_I2C lcd(0x38, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address // Define the pins the I2C 8-bit expander chip uses for LCD connections: // addr, en,rw,rs,d4,d5,d6,d7,bl,blpol LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // LCD I2C address and my PCF8574 pin assignment
The BACKLIGHT_PIN is being managed by the I2C adapter board. References to this definition may be removed. Pin 13 is NOT connected to any backlight control.
Other links:
http://wiki.sunfounder.cc/index.php?title=I%C2%B2C_LCD1602 https://opencircuit.shop/resources/file/da88acc1702a90667728fcf4ac9c75c455475706466/I2C-LCD-interface.pdf https://create.arduino.cc/projecthub/akshayjoseph666/interface-i2c-16x2-lcd-with-arduino-uno-just-4-wires-273b24 https://www.makerguides.com/character-i2c-lcd-arduino-tutorial/ https://www.electrodragon.com/w/1602_LCD