error: 'POSITIVE' was not declared in this scope

Hello,

I am getting the following error every time I compile this code:

error: 'POSITIVE' was not declared in this scope

AND

error: 'class LiquidCrystal_I2C' has no member named 'backlight'

I checked the header files.

LCD.h contains the typedef enum { POSITIVE,NEGATIVE } t_backlighPol;

as well as:

void backlight(void); and void noBacklight(void);

COMPUTER: laptop running Windows 7 (32-bit)

BOARD: Arduino UNO R3

LCD: QC2004A with LCM1602 IIC V1 backpack

SOFTWARE: Arduino IDE 1.0.5

LIBRARY: LiquidCrystal _V1.2.1 (Have tried previous versions as well [V1.2.0 and 1.1.7.1])

------------------------------------------CODE BELOW------------------------------------------------

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

/* YourDuino.com Example Software Sketch
DHT11 Humidity and Temperature Sensor test
Credits: Rob Tillaart
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=162
terry@yourduino.com */

/-----( Import needed libraries )-----/
#include <dht11.h>

/-----( Declare objects )-----/
dht11 DHT11;
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

/-----( Declare Constants, Pin Numbers )-----/
#define DHT11PIN 2

void setup() /----( SETUP: RUNS ONCE )----/
{
lcd.backlight();
Serial.begin(9600);
lcd.begin(20,4);
lcd.setCursor(0,0);
lcd.print("DHT11 TEST PROGRAM ");
lcd.setCursor(0,1);
lcd.print("LIBRARY VERSION: ");
lcd.setCursor(0,2);
lcd.print(DHT11LIB_VERSION);
delay(2000);
lcd.clear();
}/--(end setup )---/
//lcd.setCursor(3,0);

void loop() /----( LOOP: RUNS CONSTANTLY )----/
{
//lcd.print("\n");

int chk = DHT11.read(DHT11PIN);
lcd.setCursor(0,0);
lcd.print("Read sensor: ");
switch (chk)
{
case 0: lcd.print("OK"); break;
case -1: lcd.print("Checksum error"); break;
case -2: lcd.print("Time out error"); break;
default: lcd.print("Unknown error"); break;
}

lcd.setCursor(0,1);
lcd.print("Humidity: ");
lcd.print((float)DHT11.humidity, 2);

lcd.setCursor(0,2);
lcd.print("Temperature: ");
lcd.print((float)DHT11.temperature, 2);

//lcd.print("Temperature (oF): ");
//lcd.println(Fahrenheit(DHT11.temperature), 2);

//lcd.print("Temperature (K): ");
//lcd.println(Kelvin(DHT11.temperature), 2);

lcd.setCursor(0,3);
lcd.print("Dew Point: ");
lcd.print(dewPoint(DHT11.temperature, DHT11.humidity));

//lcd.print("Dew PointFast (oC): ");
//lcd.println(dewPointFast(DHT11.temperature, DHT11.humidity));

delay(2000);
}/* --(end main loop )-- */

/-----( Declare User-written Functions )-----/
//
//Celsius to Fahrenheit conversion
double Fahrenheit(double celsius)
{
return 1.8 * celsius + 32;
}

//Celsius to Kelvin conversion
double Kelvin(double celsius)
{
return celsius + 273.15;
}

// dewPoint function NOAA
// reference: Algorithms - Schlatter and Baker
double dewPoint(double celsius, double humidity)
{
double A0= 373.15/(273.15 + celsius);
double SUM = -7.90298 * (A0-1);
SUM += 5.02808 * log10(A0);
SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
SUM += log10(1013.246);
double VP = pow(10, SUM-3) * humidity;
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558-T);
}

// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: Dew point - Wikipedia
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity/100);
double Td = (b * temp) / (a - temp);
return Td;
}

/* ( THE END ) */

--------------------------------------------END OF CODE-----------------------------------------------------------

the rest of the code is working fine. I can see the temp, humidity and dew point but no BACKLIGHT!!
any help on this would be great.

Thanks,

Paul Knipe

Look at the I2C LiquidCrystal folder in your Libraries folder and look at the spelling of the folder name.
If it is spelled "LiquidCrystal_I2C" it is the wrong library for the display code you are using.
You need fm's library from here :
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
When you remove the old library (you can't just rename it) and install fm's library , the new library
folder name will be "LiquidCrystal" , NOT "LiquidCrystal_I2C".
I use both libraries because I have two different I2C displays, one works with fm's library, the other works
with the other one that I believe is the one you have. I have a Temp folder on another drive . When
I need to change libraries, I delete the old one and copy and paste the correct one into the
C:\Program Files\Arduino folder.
I don't know how to get both displays to work with the same library. I don't know if that is even possible.
I do know that the way I deal with it now works every time and takes about 1 minute.
If someone can tell me how to get both displays working with the same library I am all up for that.

1 Like

It is LiquidCrystal.

I even installed a brand new copy of Arduino with the correct libraries on a new PC with Windows XP and I got the same messages.

I tried this on a MAC and only get the error: 'POSITIVE was not declared in this scope.

The backlight error messafe did not appear. However I was unable to get the backlight working with the MAC either.

1 Like

Is this the same library you were using before or did you just install it ? (twice)
Try this library.
It should have worked with the V1.2.1 because I only had to use that library if the descriptor had
the word NEGATIVE or POSITIVE. The other lcd doesn't have that in the descriptor.
I'm stumped. How did you install the library ?
Did you make sure to close any open instances of the IDE after changing libraries ?
Have you tried just loading the "hello world" Example using "File\Examples\LiquidCrystal\Examples\Helloworld" ?

1 Like

I did the "Hello World" and had to modify it since it was written for 16x2 display.

The backlight will continuously flash rapidly and the display shows odd characters all over the place.

I have tried both of those libraries in the past with no success.

I unzip the folder and copy it to the LIBRARY directory and remove the older version.

it seems odd that it hasn't worked on any platform I have tried this on. (MAC, WINXP, WIN7)

I do know the BACKLIGHT works because when I power cycle it, the display lights up for a few seconds then goes out.

1 Like

Where did you get this ?

 LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

Did you use the "Guesser" program ?

1 Like

http://arduino-info.wikispaces.com/LCD-Blue-I2C

it is a project I am building.

So far everything works except the dang BACKLIGHT

what is the guesser program?

1 Like

The title of your post was a compiler error.

error: 'POSITIVE' was not declared in this scope
AND
error: 'class LiquidCrystal_I2C' has no member named 'backlight'

Now you're saying everything works except the backlight.

the rest of the code is working fine. I can see the temp, humidity and dew point but no BACKLIGHT!!

These two statements are contradictory.
If you sketch does not compile, how could your display be working ?
Can you please clear up this confusion ?
If the reason for your post is no longer valid, you need to state that. (ie: Sketch is compiling with no
errors using [blank] library and [blank] sketch, (preferably with links so someone else can
test it themselves). Is it displaying "hello world" ?
Are you getting valid text ?
You need to state this explicitly .
What is your current situation ?
The backlight is a separate issue , not related to your post title.
There may be a simple explanation for that.
You should not be using LCD.h. That lib is bogus.
The example at the link you gave me does NOT have "include LCD.h"
You should be using LiquidCrystal.h

  #include <Wire.h>  // Comes with Arduino IDE
// Get the LCD I2C Library here: 
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
//                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

download the guesser from this link and run it to confirm the descriptor info.
http://forum.arduino.cc//index.php?topic=157817.msg1235230#msg1235230

IMPORTANT NOTE:
You need to set your serial monitor line ending to "NEWLINE" or it will not work !
Try the attached library. NOTE THE SPELLING OF THE FILE IS DIFFERENT ! (*.rar file , and it is I2CV1-1, NOT V1.21)
This is the OTHER library I referred to .

LiquidCrystal_I2Cv1-1.rar (15.5 KB)

When I say the rest of the code is working fine, I mean that once I remove the options for lcd.backlight and POSITIVE I can get the rest of the code to compile and display on the screen.

So I downloaded the Guesser and used the library you suggested and got the following errors when trying to compile it:

------------------------------------------ERROR--------------------------------------
i2cLCDguesser:328: error: 'POSITIVE' was not declared in this scope
i2cLCDguesser:335: error: 'POSITIVE' was not declared in this scope
i2cLCDguesser:336: error: 'NEGATIVE' was not declared in this scope
i2cLCDguesser:337: error: 'NEGATIVE' was not declared in this scope
i2cLCDguesser:338: error: 'NEGATIVE' was not declared in this scope
i2cLCDguesser:339: error: 'POSITIVE' was not declared in this scope
i2cLCDguesser:340: error: 'POSITIVE' was not declared in this scope
i2cLCDguesser.pde: In function 'int guessconfig(uint8_t)':
i2cLCDguesser:364: error: 'POSITIVE' was not declared in this scope
i2cLCDguesser:380: error: no matching function for call to 'LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t&, uint8_t&, uint8_t&, uint8_t&, uint8_t&, uint8_t&, uint8_t&, uint8_t&, uint8_t&, int&)'
C:\Users----------\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:57: note: candidates are: LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t, uint8_t, uint8_t)
C:\Users------------\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:55: note: LiquidCrystal_I2C::LiquidCrystal_I2C(const LiquidCrystal_I2C&)

-------------------------------------------END OF ERROR--------------------------------------------

MY BAD.
I actually forgot to mention that the library I suggested is another one you could
try but it happens to be a library that is NOT compatible with the GUESSER.
I forgot to mention try the guesser first and then the other one.
You can get "fm's" library from here:
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
THIS is the library that works with the GUESSER.

LiquidCrystal_V1.2.1.zip (485 KB)

The once you provided in the link.

I presume you mean the author of the code: F Malpartida

ROGER THAT

So is this an unusual situation or have you seen this before?

I won't know until you run the guesser with fm's library installed.

BTW, you used the wrong button to post your code.
You used the "QUOTE" button instead of the CODE [#] button, that's why I can't scroll through
your code. The [#] code button is the one that creates a scroll window.
It is also usefull for really long quotes.

I did a test compile of your code using fm's library and got PAST the lcd descriptor.
The only compiler errors were for the dht11 humidity sensor library which I don't have installed (and never heard of
till now). After commenting out the dht11 code lines the sketch compiled.
I don't think that is good news..

The only way to get this error is that fm's library is not properly installed.
It could be that some other library is being used instead
OR
It could be that the header file LiquidCrystal_I2C.h is not being found.

Did you make sure to remove any other LIquidCrystal_I2C library that was previously installed?

The Arduino disables warnings and some errors by default so you won't
so you may not see the message about a .h file not found.

If you turn on verbose output messages you can see more warnings and
the include paths. By looking at the include paths you will see which
library is being used.

I'll go update the guesser sketch to bomb out with an error when
the wrong library is being used.

--- bill

1 Like

I got the dht11 lib from this link and installed it but I'm still getting errors for that code. I guess that
is not important right now.

I just updated the guesser sketch to error off if it detects that the wrong library is being used.

raschemmel,
I would recommend not attaching libraries to the forum posts.
Use links instead. Preferably a link to a download page were the library is
rather than a link to the download image itself. That way old stale and perhaps broken libraries don't
get left around in forum posts for unsuspecting users to stumble on again
in the future.
And if a newer version is available, the link provided can help users find it.

--- bill

Roger that.
I'll use links from now on.