1602 LCD using I2C Adapter: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
===Hardware=== | ===Hardware=== | ||
[[File:1602 I2C LCD.jpg|300px]] | [[File:1602 I2C LCD.jpg|300px]] | ||
[[File:1602_I2C_Mega2560.jpg|300px]]<br> | |||
All of these 1602, 2002, 2004 LCD modules use the same HD44780 controller chip.<br> | All of these 1602, 2002, 2004 LCD modules use the same HD44780 controller chip.<br> | ||
Documentation for HD44780 controller chip: '''https://www.sparkfun.com/datasheets/LCD/HD44780.pdf'''<br> | |||
Documentation for the PCF8774A: '''https://www.ti.com/lit/ds/symlink/pcf8574a.pdf'''<br> | |||
Here's a schematic showing how the PCF8574 connects to the LCD:<br> | Here's a schematic showing how the PCF8574 connects to the LCD:<br> |
Latest revision as of 13:00, 25 January 2021
Hardware
All of these 1602, 2002, 2004 LCD modules use the same HD44780 controller chip.
Documentation for HD44780 controller chip: https://www.sparkfun.com/datasheets/LCD/HD44780.pdf
Documentation for the PCF8774A: https://www.ti.com/lit/ds/symlink/pcf8574a.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