LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2); // Change to (0x27,16,2) for 16x2 LCD.
void setup() {
// Initiate the LCD:
lcd.init();
lcd.backlight();
}
void loop() {
// Print 'Hello World!' on the first line of the LCD:
lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
lcd.print("Hello World!"); // Print the string "Hello World!"
I would recommend using the hd44780 library instead.
It comes with the hd44780_I2Cexp i/o class which supports using PCF8574 based backpacks.
It will auto detect the i2c address and the pin mapping used on the backpack. (not all i2c lcd backpacks use the same pin mapping)
It is available in the IDE library manager so you can install it directly from the IDE without having download anything like a zip file.
Once installed, you can access the hd44780 library documentation from the "Documentation" sketch example.
The i/o class you want to use is hd44780_I2Cexp.
First run the included diagnostic sketch I2CexpDiag to verify that everything is working.
Then you look at the included hd44780_I2Cexp i/o class examples.
You can also read about it on the github page: I would recommend using the hd44780 library instead.
It comes with the hd44780_I2Cexp i/o class which supports using PCF8574 based backpacks.
It will auto detect the i2c address and the pin mapping used on the backpack. (not all backpacks use the same pin mapping)
It is available in the IDE library manager so you can install it directly from the IDE without having download anything like a zip file.
Once installed, you can access the hd44780 library documentation from the "Documentation" sketch example.
The i/o class you want to use is hd44780_I2Cexp.
First run the included diagnostic sketch I2CexpDiag to verify that everything is working.
Then you look at the included hd44780_I2Cexp i/o class examples.
Also, that MKR1310 appears to be a 3.3 volt volt device.
If your LCD 1602 doesn't match this voltage, it could explain the problem.
Does the LCD 1602 have an unpopulated 8 pin chip footprint ? If so, it is a 5 volt device.
If you mix voltages, i.e. run the display at 5 volts, you should use level shifters on SDA/SCL.