old LCD sainsmart work with old arduino IDE but not with new

Hy,
I have an old LCD, the problem is that I'm not able tu make it work with new arduino ide 1.8.12 but the same work with arduino ide 1.6.5

I test a basic sketch

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);  // 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.print("FIRST LINE TEST"); 
  lcd.setCursor ( 0, 1 );        // go to the 2nd line
  lcd.print("SECOND LINE TEST"); 
  lcd.setCursor ( 0, 2 );        // go to the third line
  lcd.print("THIRD LINE TEST"); 
  lcd.setCursor ( 0, 3 );        // go to the fourth line
  lcd.print("FOURTH LINE TEST"); 
  
}

void loop()
{
}

I use the same library (the old one) but also if I use

https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home#!downloading-and-installation

What could be the problem?

Thanks!

Elegant as fmalpartida's library was in its day, now you should install the HD44780 library using the library manager of the latest Arduino IDE and use the examples and application code it provides. :sunglasses:

Thanks, I tried but not solved.

The problem isn't at compile time, the sketch compile and upload correctly on board, but if I use the old ide the LCD write the correct words, If I use actual IDE the LCD show 1 ore 2 char or leave 2 line "white"

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.

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.

suche:
Thanks, I tried but not solved.

The problem isn't at compile time, the sketch compile and upload correctly on board, but if I use the old ide the LCD write the correct words, If I use actual IDE the LCD show 1 ore 2 char or leave 2 line "white"

The hd44780 library does not have the issue you are describing.
The examples provided in the hd44780_I2Cexp i/o class should "just work" out of the box with no changes needed.
There is no need to even set the i2c address as it will auto locate the i2c address of the backpack.

From the code you are using and the symptoms you describe,
it appears that you are using the H. Mario LiquidCrystal_I2C library.
That LCD library had a bug in it that didn't show up in older versions of the Arduino Print class (which comes bundled with the IDE)
While it "works" with older versions of the IDE but has issues with the newer versions, the bug/issue is in the library not the IDE.
The fix is simple (one line of code), but that library is not very well maintained.
It has been fixed, but there is an issue in the github repository for that library that can causes the IDE not to be able to get the updated version of the library.

I would recommend using the hd44780 library.
better maintained, easier to use, more feature rich, and faster.

--- bill

Thankyou very very very much!!!

I spent one day making tons of changes and trying anything...

I completely disintalled arduino, ccleaner, reinstall arduino 1.8.12, installed the hd44780 library and the sketch "Hello World!" run correctly!

Also with the previous installation the compiler completed the upload, no code errors, but the LCD only show 2 line with all pins on, or other times, it show 2-3 char.

Now, it seems that what you compile is what you see :smiley:

We were waiting for that. :grinning:

If the HD44780 library and examples do not work, then something (else) is really fouled up! :astonished: