Go Down

Topic: error: 'POSITIVE' was not declared in this scope (Read 91209 times) previous topic - next topic

paupline

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------------------------------------------------

Quote

#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: http://wahiduddin.net/calc/density_algorithms.htm 
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: http://en.wikipedia.org/wiki/Dew_point
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

raschemmel

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.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

paupline

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.



raschemmel

#3
Jan 30, 2014, 09:46 pm Last Edit: Jan 31, 2014, 04:15 am by raschemmel Reason: 1
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" ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

paupline

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.

raschemmel

Where did you get this ?
Code: [Select]
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 
Did  you use the "Guesser" program ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

paupline

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?

raschemmel

#7
Jan 30, 2014, 11:32 pm Last Edit: Jan 31, 2014, 12:34 am by raschemmel Reason: 1
The title of your post was a compiler error.
Quote
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.
Quote
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
Code: [Select]
  #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 .
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

paupline

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--------------------------------------------


raschemmel

#9
Jan 31, 2014, 02:07 am Last Edit: Jan 31, 2014, 04:17 am by raschemmel Reason: 1
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.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

paupline

The once you provided in the link.

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

raschemmel

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

paupline

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

raschemmel

I won't know until you run the guesser with fm's library installed.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

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.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Go Up