Hi,
I am using a liquid crystal_I2C.h library for using the LCD 16*2. But I am getting the following error:
'POSITIVE' was not declared in this scope
I have tried a lot to install lots of different versions of the liquid crustal library but could not fix the error. I could find a reason that "the penultimate library" can fix this issue but I could not understand what is it and did not find such a library. I am trying to implement this project: https://www.instructables.com/id/Milliohm-Meter/
I am totally new to the arduino world, any help on this would be highly appreciated.
Regards,
Mehdi
For trouble-free I2C LCDs, install the hd44780.h library from the library manager.
The code below should display hd44780
// i2c ld template
#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
// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
lcd.begin(LCD_COLS, LCD_ROWS);
lcd.setCursor(0, 0);
lcd.print(" **hd44780** ");
delay(1000);
}//setup
void loop()
{
//
}//loop
The commands to use the library are the same as any other lcd code, so setCursor() and so on all work as expected.
I have checked the internal library files of the liquid crystal i2c library but didn't find 'POSITIVE' there. O think you should reinstall the library and write the code again. I think it will help.
There are multiple I2C LCD libraries. If you download one, you need to base your sketch on the examples that come with it. Following an example that was not written with the same library in mind will cause the problem that you experience.
Either follow the advise above about the HD44780 library or find the library that was intended to be used. For the latter, this can be a google search: github liquidcrystal_i2c positive
Hi,
Thanks for all of your comments and information. Finally I could compile it and connect it to I2C. I have also tried a couple of different type if LCD codes like blinking, hellow word and even diffferent versions. But the LCD always turns on all the pixels in the first row and nothing changes. I have checked the connections a couple of times butcould not fix it, any idea of what would be the issue?
Regards,
Mehdi
mehdina94rm:
any idea of what would be the issue?
I'm going to go out on a limb here and guess that the problem has something to do with the way your code (which you haven't shown us) interacts with the library that you're using (which you haven't specified).
Thanks for the comment. Here is the code I am using:
//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#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
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(3,0);
lcd.print("Hello, world!");
lcd.setCursor(2,1);
lcd.print("Ywrobot Arduino!");
lcd.setCursor(0,2);
lcd.print("Arduino LCM IIC 2004");
lcd.setCursor(2,3);
lcd.print("Power By Ec-yuan!");
}
void loop()
{
}
any idea of what would be the issue?
There are different modules with different wiring connections between the i2c interface chip and the hd44780 lcd controller chip. It's possible that the assumptions of the LiquidCrystal.h library as to the wiring of the chip is wrong.
That is why it was recommended to use Bill Perry's hd44780.h from the library manager.
It will auto configure the code for whatever controller arrangement exists. If there are still problems, there is a diagnostic sketch which will figure out what is going on.
Don't fiddle about. Go to the library manager and install hd44780.h . Follow the example of posting #2 for use of the i2c_exp i/o class
#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
Thanks for your comment. I actually tried that code and library also but I have the same problem. I even removed the SDA and SCL wires but nothing changes. Is there any chance that I damaged the LCD and it is always on and all the pixels are on?
Regards,
Mehdi
Run the diagnostic sketch in the library. I2CexpDiag. Be sure to read the notes that are at the start of the program. Report back on what it tells you.