I had tried 2 kinds of LiquidCrystal libraries <LiquidCrystal_I2C.h> and <LiquidCrystal_PCF8574> , but both of the results are failed.
I also changed the potentiometer behind it, but it failed.
Please help me with this problem
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Hello World");
lcd.setCursor(0,1);
lcd.print("Hello World2");
}
void loop()
{
}
I do not know if the hd44780 library will work with the Portenta, but if it will it is the best library for the HD44780 controlled I2C enabled displays. Perhaps @bperrybap can answer the question if his library is compatible.
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.
I'm not familiar with the Portenta H7, but it is 3v vs 5v.
I always use a level shifter when using 3v processors with 5v i2c slave devices.
I would recommend using the hd44780 library hd44780_I2Cexp i/o class.
In the IDE library manager, if you search for "bperrybap" or "duinowitchery", you can easily find the library.
Run the included diagnostic test I2CexpDiag, and it will test the h/w and report any issues that it can detect.
Here is link to the hd44780_I2Cexp i/o class wiki:
I'm curious on the selection and use of the Portenta H7.
Like why use it vs a Raspberry pi instead?
The pi is much cheaper has a real OS, pretty much any s/w tool imaginable, and full s/w development tools.
The Raspberry pi zero 2 w price is about $15 has a faster processor with more memory and includes video, audio, usb, wifi and bluetooth, sd card disk, on board.
Update:
I use the library hd44780--> io class --> i2cExp --> Hello Word.
it work fine
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
// hd44780_I2Cexp lcd1(0x20);
hd44780_I2Cexp lcd2(0x27);
// LCD geometry
const int LCD_COLS = 40;
const int LCD_ROWS = 2;
void setup() {
int status;
status = lcd2.begin(LCD_COLS, LCD_ROWS);
if (status) // non zero status means it was unsuccesful
{
hd44780::fatalError(status); // does not return
}
lcd2.print("Hello Word");
}
void loop() {}