What am I doing wrongly to it not work?

Hi. I buy a simple LCD and I can't make it work. I always get an error message when I go to compile it. This is so frustrating.

I have tried to read in a lot of place, get a lot of library and even in the original manufacturer and it NOT WORK!!

What am I doing wrongly??? The LCD is: I2C lcd1602 (see the picture) from www.mjkdz.com. I get the LiquidCrystal_I2C.h library. I install this in library folder or just put it in the same folder of source code.

Than I try to run this "Hello Word" code:

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

LiquidCrystal_I2C lcd(0x20,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()
{
}

And I get this error message:

HelloWorld:4: error: invalid conversion from 'int' to 't_backlighPol'
HelloWorld:4: error: initializing argument 3 of 'LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t, uint8_t, t_backlighPol)'
/Users/rodrigozanattasilva/Documents/Arduino/libraries/LiquidCrystal/LiquidCrystal_I2C.h: In function 'void setup()':
/Users/rodrigozanattasilva/Documents/Arduino/libraries/LiquidCrystal/LiquidCrystal_I2C.h:154: error: 'int LiquidCrystal_I2C::init()' is private
HelloWorld:8: error: within this context

It can't be just a invalid conversion.. I always get some type of error like this. How I make it work????

Where did you get this "hello world" code ?

I've got a working sketch that uses a library with the same name (...).
It uses

LiquidCrystal_I2C	lcd(LCD_A,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

And:

  lcd.begin (16,2);

To set and start communication with the LCD.
The first one tells about what wires are connected between I2C interface and display, and teh second one tells about what display is in use.

Have you considered searching for the term 'mjkdz'? There's a search box at the top of this page.

Don

I try to search this model in the forum and didn't find :cold_sweat: maybe I am angry because it not work :slight_smile:

I try to search this model in the forum and didn't find maybe I am angry because it not work

Type the letters mjkdz in the white box at the top right corner of this page and then click on the word Search that is next to the box.

Don

If the library is in the sketch folder change #include <LiquidCrystal_I2C> to #include "LiquidCrystal_I2C" this tells the compiler to look in the sketch directory first. It's not a great idea because it doesn't place the lib files in the "Right" place but it will allow the compiler to find the library... Saving multiple copies as a work in progress is harder and this is why the "Users\This User\My Documents\Arduino\libraries where This User is your user name... is the best method.

Doc

[Fixed a typo.. RKJ]

Thanks Docedison and MAS3!! You two find the error.

But there are others. This is one of the example of this library and it has a lot of errors. This code will work better:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h> //Yes, if you put "" it will find in the same folder and will work!

LiquidCrystal_I2C lcd(0x20);  // This is the correct way to initialize it!!

void setup()
{
  lcd.begin(16,2);                      //Why the author use init? This is the correct way.
 
  // Print a message to the LCD.
  lcd.backlight();
  lcd.print("Hello, world!");
}

void loop()
{
}