'POSITIVE' was not declared in this scope error LCD Display 2004a

Hello Guys,
i want to run the LCD Display 2004a on my arduino uno but i get always the compilation error you can see in the subject. I'm new to this arduino stuff so i can't identify the failure. Can somebody help me?

#include <Wire.h>
#include <LiquidCrystal_I2C.h> //https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

// Belegung für 16x4 LCD-Modul QC2204A
// mit Sainsmart LCD2004 I2C-Controller
LiquidCrystal_I2C  lcd(0x27,2,1,0,4,5,6,7,3,POSITIVE);

void setup() {
  lcd.begin(20,4);
  lcd.setCursor(4,1);
  lcd.print("Hallo Welt!");
  delay(5000);
}

void loop() { 
  //Display löschen und Cursor nach oben links
  lcd.clear();
  lcd.home();
  
  //---Zeilen ansprechen
  lcd.setCursor(4,0);
  lcd.print("Zeile 1");
  lcd.setCursor(5,1);
  lcd.print("Zeile 2");
  lcd.setCursor(6,2);
  lcd.print("Zeile 3");
  lcd.setCursor(7,3);
  lcd.print("Zeile 4");
  delay(2000);
  
  //---Display-Inhalt nach rechts scrollen
  lcd.scrollDisplayRight();
  //lcd.scrollDisplayLeft()
  delay(2000);
  
  //---Cursor ein  
  lcd.clear();
  lcd.home();
  lcd.print("Cursor blinkt:");
  lcd.setCursor(0,1);
  lcd.blink();
  delay(2000);
  
  //---alternativer Cursor
  lcd.clear();
  lcd.home();
  lcd.print("Cursor Unterstrich:");
  lcd.setCursor(0,1);
  lcd.cursor();
  delay(2000);
  
  //---Zurücksetzen
  lcd.clear();
  lcd.home();
  lcd.noCursor();
  lcd.noBlink();
  
  //---Alle Zeichen anzeigen
  lcd.print("Alle Zeichen...");
  delay (2000);
  lcd.clear();
  lcd.setCursor(2,0);
  int i=1;
  for (char c = -128; c < 127; c++,i++){
    lcd.print(c);
    if (!(i%16)) lcd.setCursor(2,(i/16)%4);  
    if (!(i%64)) delay(3000);
  }
  delay(3000);

  //---Display aus
  lcd.clear();
  lcd.home();
  lcd.print("Display aus...");
  delay(2000);
  lcd.off();
  delay(2000);
  //---Display wieder an
  lcd.on();
  //lcd.noBacklight();
  //lcd.backlight();
}

Did you see https://www.sainsmart.com/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html

No I didn't saw that but if I try to run the example sketch i got this error:

In file included from C:\Users\myname\Desktop\Arduino\Display\Display.ino:27:0:

C:\Users\myname\Documents\Arduino\libraries\LCD/LCD.h:20:22: fatal error: WProgram.h: No such file or directory

#include "WProgram.h"

^

compilation terminated.

Try reading their Wiki

I don't find something in the wiki which would help me...
Sorry if i behave stupidly but i don't get it:/

You could try contacting them for support.

I am confused, because it seems you report two different errors.

The error with #include "WProgram.h" may indicate you use a library made for a very old version of the Arduino IDE. If this #include "WProgram.h" is in an actual library, it is conditional, in effect only of old Arduino versions.

Jean-Marc

This issue is very common and there are many threads about this.
But unfortunately this forum has no search capability.
They removed it and instead replaced with a fairly useless google search of the site so it is very difficult to find old threads.

ZinggJM:
I am confused, because it seems you report two different errors.

The error with #include "WProgram.h" may indicate you use a library made for a very old version of the Arduino IDE. If this #include "WProgram.h" is in an actual library, it is conditional, in effect only of old Arduino versions.

Jean-Marc

That isn't necessarily true. There are some versions of the IDE that are very broken.
They didn't use the C pre-processor and attempted to locate the header files themselves using java code.
The issue is that those IDE versions will attempt to locate header files even thought they are inside conditionals that should hide them.

The issue in this case is that the sketch is attempting to use a library that either is not installed or installed incorrectly.
LiquidCrystal_I2C libraries are a real mess.
I've written about this in MANY threads.
The main reason that there are so many versions of them floating around out there.
Some are very old and may use header files that either no longer exist or have changed names.
Then there is the difference between the LiquidCrystal_I2C library and using the LiquidCrystal_I2C i/o class from fm's newLiquidCrystal library.
Both use the same name.
These are two completely different libraries and they initialized and work differently and have slightly different APIs.
The example sketch in the first post is expecting fm's newLiquidCrystal LiquidCrystal i/o class.

LiquidCrystal_I2C is available using the library manger.
fm's newLiquidCrystal library must be manually installed.
LiquidCrystal_I2C has hard coded PCF8574 pin mappings that may or may not work with given backpack.
newLiquidCrystal LiquidCrystal_I2C i/o class can work with any backpack but requires that the sketch configure the pin mappings in the lcd object constructor.
Both require configuring the i2c address of the backpack.

For an easier "plug and play" option, I'd suggest that you try using my hd44780 library package.
It includes an i/o class, hd44780_I2Cexp, that will automatically locate the i2c address and auto detect the pin mappings making it easier to use.
It includes a diagnostic sketch to test the i2c signals and the internal memory of the LCD module.
It can quickly and easily be installed using the IDE library manager.
You can read more about it here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
That page has additional information, including licensing information (GPLv3), along with s/w & h/w requirements, installation instructions, and a summary of the API functions available.

After installing the library the first thing to run is the diagnostic sketch I2CexpDiag.

--- bill

These LCD displays obviously are widely used and generate many topics. Seems all Newbies like me make similar experiences with them (my experience with 20x4 is still waiting to be made).

So I would suggest to provide a general topic for LCD support, and make it a sticky topic, like the LCD keypad warning.

Jean-Marc

There's a whole forum section for them, why mash a ton of unrelated discussions into one thread?

Did you find the solution to your error yet?

My main error is the one with "POSITIVE" was not declared...
The other one just poped up after I tried the stuff which you can find at the link which was posted by ieee488. I really need your help on finding the solution because I need the display working for a school project and the deadline for this is on friday.
@pert: no I didn't found it yet... :confused:

It's actually a very common error reported here. A bit of searching never hurts. I believe you're the second to report it this week.

I suspect the problem is you're using the wrong library. There are multiple libraries named "LiquidCrystal_I2C". Luckily for you the URL of the correct library is right there in the comments. So try this:

If you still have an error then do this:

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here using code tags.

tnk:
My main error is the one with "POSITIVE" was not declared...

No that is not your main error.
You main error is what I said in post #7

The issue in this case is that the sketch is attempting to use a library that either is not installed or installed incorrectly.

I gave you everything you need to get something up and working in post #7.
It comes down to 3 basic options:

  • Switch to using the LiquidCrystal_I2C library that is available in the IDE library manger
    This library may or may not work with your backpack, even if you tell it your correct i2c address.

  • Install fm's newLiquidCrystal properly.
    You must read the instructions for installation as using the zip import isn't the proper way to install it.
    https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
    Then you must make sure that the i2c address and pin mappings you put in the constructor are correct.
    If you get any of that information incorrect, it will not work.

  • Install my hd44780 library using the IDE library manager.
    You can be up and running in literally less than 1 minute.
    It figures out all the i2c and pin configuration information for you.
    It even includes a diagnostic sketch to help detect issues.


The choice is obviously yours, but if you want the easiest and quickest way to get the LCD & backpack up and working, I'd suggest that you take the advice I offered back in post #7.

--- bill

pert:
There's a whole forum section for them, why mash a ton of unrelated discussions into one thread?

Did you find the solution to your error yet?

Thank you for your contribution.

"What do you mean by forum section" is the question that passed immediately through my mind, and maybe not only mine.

Contributions that provide clickable links to additional information is what I find most useful.

Jean-Marc

The "Displays" section of the Arduino forum:
http://forum.arduino.cc/index.php?board=7.0

bperrybap:
No that is not your main error.
You main error is what I said in post #7

I gave you everything you need to get something up and working in post #7.
It comes down to 3 basic options:

  • Switch to using the LiquidCrystal_I2C library that is available in the IDE library manger
    This library may or may not work with your backpack, even if you tell it your correct i2c address.

  • Install fm's newLiquidCrystal properly.
    You must read the instructions for installation as using the zip import isn't the proper way to install it.
    https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
    Then you must make sure that the i2c address and pin mappings you put in the constructor are correct.
    If you get any of that information incorrect, it will not work.

  • Install my hd44780 library using the IDE library manager.
    You can be up and running in literally less than 1 minute.
    It figures out all the i2c and pin configuration information for you.
    It even includes a diagnostic sketch to help detect issues.


The choice is obviously yours, but if you want the easiest and quickest way to get the LCD & backpack up and working, I'd suggest that you take the advice I offered back in post #7.

--- bill

Hello Bill

I took my 2004A out of the storage drawer it was waiting to be used, to try to get experience with.
I had used a I2C 2x16 LCD some time ago, with the LiquidCrystal_I2C library.
I had used I2C_scan then, so my start was easy.

The Hello Word example of LiquidCrystal_I2C runs fine, with the parameters 0x27,20,4.

Then I wanted to try an example of hd44780. I had installed the library previously, and it is kept up to date. But no "Hello World" to start with. Which example should I start with?

I tried some, but it complained about missing configuration. I might surely find out, but reporting here is easier.

Maybe a separate forum section should be dedicated to LCDs. My focus was on EPDs and TFTs so far.
I did not guess that the "section for LDC" is the whole Arduino Displays section.

Jean-Marc

Aha, I found an example to take:

C:\Users...\Documents\Arduino\libraries\hd44780\examples\OtherLibraries\LiquidCrystal_I2C\hd44780examples\LCDlibTest

this was not obvious for me.

The moving graphics bar graph even looks like colored, but this seems to be an artifact.

Jean-Marc

ZinggJM:
Aha, I found an example to take:

C:\Users...\Documents\Arduino\libraries\hd44780\examples\OtherLibraries\LiquidCrystal_I2C\hd44780examples\LCDlibTest

this was not obvious for me.

While that is "an example" it is the wrong example if you want to try the hd44780 hd44780_I2Cexp i/o class.
That example is using the LiquidCrystal_I2C library not the hd44780 library and the hd44780_I2Cexp i/o class.
You should read the information & documentation on the github repository.
There are many readme files that describe the examples.
They automatically come up in the browser as you click down into the various example directories in the repository.

If you want to try/test the hd44780 library on your backpack, you need to run examples for the hd44780_I2Cexp i/o class.

And the first example to run is the I2CexpDiag sketch which runs a full diagnostic on the i2c bus and the LCD memory.

--- bill

This worked for me:

pert:
It's actually a very common error reported here. A bit of searching never hurts. I believe you're the second to report it this week.

I suspect the problem is you're using the wrong library. There are multiple libraries named "LiquidCrystal_I2C". Luckily for you the URL of the correct library is right there in the comments. So try this:

If you still have an error then do this:

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here using code tags.

try to use my library. it's much faster than others - GitHub - enjoyneering/LiquidCrystal_I2C: This is an Arduino library for HD44780 LCD display, operated in 4 bit mode over I2C bus with 8-bit I/O expander PCF8574