0

I am using Arduino IDE 1.6.8 and I am trying to compile the following code Wheatstone Bridge. I have currently a really weird error:

unknown type name 'LiquidCrystal'

This error seems to come from the header file:

// Include the Wheatstone library
#include <WheatstoneBridge.h>

// Include the LCD library
#include <LiquidCrystal.h>

// Declare external global lcd
extern LiquidCrystal lcd; <<<Error

I have already installed the LiquidCrystal library but I don't know if this trouble is due to the compiler (and the IDE) or something is wrong. The compiler seems to find the right libraries...

  • "I have already installed the LiquidCrystal library" ... It already comes with the IDE, so what exactly did you install? – Ignacio Vazquez-Abrams May 3 '16 at 11:48
  • @IgnacioVazquez-Abrams You are right. I don't install it. This library is installed with the IDE and the compiler find it well. – Guuk May 3 '16 at 11:50
1

Using "extern" when instantiating a class is unusual. We can not tell what your intentions are because this is only part of your code. However it would be my guess that this code:

// Declare external global lcd
extern LiquidCrystal lcd;

Should actually be written like this:

// Declare external global lcd
LiquidCrystal lcd((12, 11, 5, 4, 3, 2);

This is making a BIG assumption that you are using an LCD similar to the one used in the HelloWorld example and you have connected it using the same pins! Comments from the HelloWorld example to help you out:

 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

Background:

Arduino sketches are written mostly in C while the libraries take advantage of C++. As such the libraries can use a C++ feature called "overloading". This is where you can have several different functions with different parameters all with the same name. The advantage is that you can call upon slightly different functions (or in this case different classes) simply by altering what is passed. The LiquidCrystal class has defined all these possibilities:

  LiquidCrystal(uint8_t rs, uint8_t enable,
        uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
        uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
  LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
        uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
        uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
  LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
        uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
  LiquidCrystal(uint8_t rs, uint8_t enable,
        uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);

But in none are there no parameters. That is why the compiler could not find the class in your code. You needed to match one of the above class types.

  • Removing extern change nothing. Obtain the same error unknown type name 'LiquidCrystal'. – Guuk May 3 '16 at 12:51
  • In the Arduino IDE: 1) Click on Sketch -> Import Library, do you see the LiquidCrystal library? 2) Double check the spelling in your code, I've been tripped up by this more than once. 3) Try compiling the HelloWorld example in the LiquidCrystal library example directory. – st2000 May 3 '16 at 12:57
  • no trouble when compiling the HelloWorld example of LiquidCrystal library – Guuk May 3 '16 at 12:59
  • Hang on, I think I need to edit my comment to pass values to the constructor. – st2000 May 3 '16 at 13:10
  • Finally this error is not the right. When I read the compilation log I have found an other error. In fact Arduino IDE try to compile using gcc and not g++ due to the fact the example folder contains one .c file. Changing the extension to .cpp solves the problem. – Guuk May 3 '16 at 13:28
0

Download the Liquidcrystal.zip file from this link, Crystal link

Now add that file into documents/Arduino/libraries folder. Now check if the library is added in the library. It should probably work.

  • Thank for your proposal but I have the same error with this library. – Guuk May 3 '16 at 12:06
  • Have read your solution, at the end of discussion. I was having similar issues, saying "IDE try to compile using gcc and not g++". Close this problem – Chaitanya May 4 '16 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.