Go Down

Topic: compiling errors <LCD4Bit.h>|<LCD4Bit_mod.h> (Read 8446 times) previous topic - next topic

keyz01

Dec 19, 2011, 04:13 am Last Edit: Dec 19, 2011, 04:19 am by keyz01 Reason: 1
Hello,

OS:Windows 7
board:arduino Uno
IDE:arduino-1.0
shield:KeyPadLCDShield

I get errors when compiling the sketch with the #include <LCD4Bit.h> old LCD library, this shield (KeyPadLCDShield from muelectronic) requires this library or the <LCD4Bit_mod.h> in order to work.
sketch>import library>LCD4Bit adds <LCD4Bit.h> in the IDE text editor.
The program never compiles, even with the first one nor the second one, the compiler sends me error messages.

arduino-1.0-windows\arduino-1.0\libraries\LCD4Bit\LCD4Bit.cpp:29:57: error: WConstants.h: No such file or directory
.........
arduino-1.0-windows\arduino-1.0\libraries\LCD4Bit\LCD4Bit.cpp:225: error: 'delay' was not declared in this scope

tested with
#include <LiquidCrystal.h>
void setup(){};  
void loop(){};
compiles successfully!

jczorglub

OS:Windows XP
board:arduino Uno
IDE:arduino-1.0
shield:KeyPadLCDShield

Hello!
Also newbie, I have the same problem.
I googled a bit, but did not find anything useful.
Could you solve this issue?
Thanks for helping a more newbie than you!

SurferTim

Open this file.
arduino-1.0-windows\arduino-1.0\libraries\LCD4Bit\LCD4Bit.cpp
At line 29, you should find this
#include <WConstants.h>
Change to
#include <Arduino.h>
The delay declaration in now in that file in V1.0.


pbendel

I have no luck as well.

I have Win7, Arduino IDE 1.0, Duemanilove

I changed line 29 in the CPP file as above to from WContstants.h to Arduino.h

It still has a whole pile of compiler errors.

Anything else I am missing?

raechten

Just received my LCD shield and had the same problem. Looking at some other libraries that are (made) v1.0 compatible, I figured out that for it to work with v1.0 arduino code, you don't need all the other libraries, just Arduino.h and the LCD4Bit_mod.h. I changed the headers in the LCD4Bit_mod.cpp file to look like this:

#include "LCD4Bit_mod.h"
#if (ARDUINO < 100)
  extern "C" {
    #include <stdio.h>  //not needed yet
    #include <string.h> //needed for strlen()
    #include <inttypes.h>
    #include "WProgram.h"
  }
#else
  #include <Arduino.h>
#endif

It now works for v1.0 and it SHOULD still work for older Arduino versions (although I have not tested that).

Hope it helps,

Robert :-)

avbeek

Thanks Robert, that worked for me on my Uno rev3!

cheers,

Arthur

yimiblu

Hello all!
I'm absolutely new here, and new on using arduino 'by myself'. I've read all what i found here about "Cannot find WConstants.h", and still cant find the problem. I'm trying to use one of the stepper motor control provided with the last version of arduino software, reporting:

In file included from stepper_speedControl.ino:20:
/Users/xxx/Documents/Arduino/libraries/Stepper/Stepper.h:52:24: error: WConstants.h: No such file or directory

but there is no reference to that "WConstants.h" file neither on that stepper.h, or .cpp or everywhere in my arduino instalation :/

I know you'll hate me, and maybe you'll ban me, but... i cant understand (yet..) :(

Thanks a lot.

Javi


keyz01

#7
Sep 25, 2013, 11:15 pm Last Edit: Sep 25, 2013, 11:30 pm by keyz01 Reason: 1
I solved the problem by downgrading from version 1.0 to 0023.
See that post http://forum.arduino.cc/index.php/topic,96356.0.html
LCD4Bit_mod is not compatible with versions > arduino 0.23.
And also notice it have to be use with HD44780 LCD driver.

crasherman

thank you Robert !

It's working for me too :) with arduino 1.0.5-r2

favwiz

Thanks.  This fix worked for the code that comes with the SainSmart LCD Keypad Shield. 

steinerrw

Tried the changes here. Nothing works.
LCD4Bit_mod.cpp change as described above.

#include "LCD4Bit_mod.h"
#if (ARDUINO < 100)
  extern "C" {
    #include <stdio.h>  //not needed yet
    #include <string.h> //needed for strlen()
    #include <inttypes.h>
    #include "WProgram.h"
  }
#else
  #include <Arduino.h>
#endif

in IDE, it has two copies of LCD4Bit_mod

these are the error msgs...

/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino: In function 'void setup()':
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino:27:43: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   lcd.printIn("KEYPAD testing... pressing");
                                           ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.pde: At global scope:
LCD4Bit_modExample:6: error: redefinition of 'LCD4Bit_mod lcd'
 LCD4Bit_mod lcd = LCD4Bit_mod(2);
             ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino:6:13: note: 'LCD4Bit_mod lcd' previously declared here
 LCD4Bit_mod lcd = LCD4Bit_mod(2);
             ^
LCD4Bit_modExample:9: error: redefinition of 'char msgs [5][15]'
 char msgs[5][15] = {"Right Key OK ",
                ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino:9:6: note: 'char msgs [5][15]' previously defined here
 char msgs[5][15] = {"Right Key OK ",
      ^
LCD4Bit_modExample:14: error: redefinition of 'int adc_key_val [5]'
 int  adc_key_val[5] ={30, 150, 360, 535, 760 };
                   ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino:14:6: note: 'int adc_key_val [5]' previously defined here
 int  adc_key_val[5] ={30, 150, 360, 535, 760 };
      ^
LCD4Bit_modExample:15: error: redefinition of 'int NUM_KEYS'
 int NUM_KEYS = 5;
     ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino:15:5: note: 'int NUM_KEYS' previously defined here
 int NUM_KEYS = 5;
     ^
LCD4Bit_modExample:16: error: redefinition of 'int adc_key_in'
 int adc_key_in;
     ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino:16:5: note: 'int adc_key_in' previously declared here
 int adc_key_in;
     ^
LCD4Bit_modExample:17: error: redefinition of 'int key'
 int key=-1;
     ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino:17:5: note: 'int key' previously defined here
 int key=-1;
     ^
LCD4Bit_modExample:18: error: redefinition of 'int oldkey'
 int oldkey=-1;
     ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino:18:5: note: 'int oldkey' previously defined here
 int oldkey=-1;
     ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.pde: In function 'void setup()':
LCD4Bit_modExample:20: error: redefinition of 'void setup()'
 void setup() {
      ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino:20:6: note: 'void setup()' previously defined here
 void setup() {
      ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.pde:27:43: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
   lcd.printIn("KEYPAD testing... pressing");
                                           ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.pde: In function 'void loop()':
LCD4Bit_modExample:31: error: redefinition of 'void loop()'
 void loop() {
      ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino:31:6: note: 'void loop()' previously defined here
 void loop() {
      ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.pde: In function 'int get_key(unsigned int)':
LCD4Bit_modExample:62: error: redefinition of 'int get_key(unsigned int)'
 int get_key(unsigned int input)
     ^
/tmp/arduino_modified_sketch_69442/LCD4Bit_modExample.ino:62:5: note: 'int get_key(unsigned int)' previously defined here
 int get_key(unsigned int input)
     ^
exit status 1
redefinition of 'LCD4Bit_mod lcd'

Any help would be appreciated. Thanks

Go Up