I'm using an Arduino MEGA 2560, and I can't seem to make my LCD screen display anything at all. The SDA and SCL pins are wired to the communication SDA and SCL pins on the board. The code compiles correctly with no error messages. The address is correct as I ran a scanner program before uploading the code below. Any suggestions?
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x20 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.print("Hello, world!");
}
void loop()
{
}
There are already MANY threads on this type issue.
It could be several things. But nearly all the issues with the i2c backpacks comes down to 2 issues.
- poor electrical connections from something like poor soldering
- incorrect s/w configuration.
There are several different designs of i2c backpacks. In these different designs , the i2c chip is wired up differently to the LCD and the backlight circuit can work differently.
The LiquidCrystal_I2C library is hard coded to one particular design. While that makes configuration in the sketch simpler, if the backpack you have is a different design it will not work and the only way to make it work is modify the library code.
You could try my hd44780 library package. It can offer plug and play for LCDs using i2c backpacks.
It supports more than just i2c backpacks so it will appear a bit complicated than other libraries, but the actual usage in a sketch is actually much simpler since it will auto locate the i2c address and probe the i2c backpack to automatically determine the pin wiring used on the backpack.
You can install the library using the library manager directly from the IDE GUI.
Once installed, run the included diagnostic sketch I2CexpDiag to verify that the library and LCD are working correctly.
The i/o class for an i2c backpack that uses an i2c i/o expander chip like the PCF8574 is called
hd44780_I2Cexp
That is what you will use. See the examples for that i/o class for the needed includes and how to declare your lcd object.
You can read more about it on the github repo page: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
There are also links to some additional information in the included Documentation sketch.
--- bill