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????
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.
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.
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()
{
}