Hi,
I would like to know how to connect a I2C LCD to an ATmega328 but I could not find a tutorial online. Does anyone know how to do this? Or is it not possible?
Which I2C LCD?
0x27 is that what you mean?
The LCD will have 4 pins on it. How are they labelled ?
No, that looks like it could be an I2C address.
I mean what device type?
A 44780 character display,or a full graphics display?I
Or something else.
A character display (1602A)
For a hd44780 controlled character LCD display with an I2C expander backpack (1602 for example).
Connect SDA to A4 on the 328.
Connect SCL to A5 on the 328.
Connect Vcc to 5V
Connect gnd to ground
For an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.
To install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE menus, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.
The class that you want to use is the hd44780_I2Cexp class. There are examples to show how to use the library. The nice thing about the hd44780 library is that it will autodetect the I2C address and the I2C backpack to LCD pin mapping.
In the examples, there is a diagnostic sketch that will help us to help you if you still have trouble with the display. Run the diagnostic sketch and post the results.
Adjust the contrast pot to the optimal viewing contrast.
groundFungus:
For a hd44780 controlled character LCD display with an I2C expander backpack.Connect SDA to A4 on the 328.
Connect SCL to A5 on the 328.
Connect Vcc to 5V
Connect gnd to groundFor an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.
To install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE menus, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.
The class that you want to use is the hd44780_I2Cexp class. There are examples to show how to use the library. The nice thing about the hd44780 library is that it will autodetect the I2C address and the I2C backpack to LCD pin mapping.
In the examples, there is a diagnostic sketch that will help us to help you if you still have trouble with the display. Run the diagnostic sketch and post the results.
Adjust the contrast pot to the optimal viewing contrast.
Thanks for the help!
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.