Pages: [1]   Go Down
Author Topic: LCD4BIT problems on Arduino 1.0  (Read 6774 times)
0 Members and 1 Guest are viewing this topic.
Chernogolovka, Moscow dst., Russia
Offline Offline
Newbie
*
Karma: 0
Posts: 43
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good evening, colleagues!

After upgrading to the IDE Arduino 1.0, I no longer compile the program to work with the LCD display.

I am using shield with an 1602 LCD display and five buttons like this here - http://www.geeetech.com/arduino-lcd-1602-keypad-shield-p-251.html
I am using Arduino IDE 1.0 for Mac OS X.

I'm downloading the library, and then unpack it and copy in the directory '/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/'.
After starting, IDE is find the library and loads of examples from it.

If you try to compile the sample LCD4Bit_modExample.pde I get the following diagnosis:
Quote
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:29:57: error: WConstants.h: No such file or directory
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp: In member function 'void LCD4Bit_mod::pulseEnablePin()':
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:58: error: 'LOW' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:58: error: 'digitalWrite' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:59: error: 'delayMicroseconds' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:61: error: 'HIGH' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:64: error: 'delay' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp: In member function 'void LCD4Bit_mod::pushNibble(int)':
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:73: error: 'digitalWrite' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp: In member function 'void LCD4Bit_mod::commandWriteNibble(int)':
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:99: error: 'LOW' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:99: error: 'digitalWrite' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp: In member function 'void LCD4Bit_mod::commandWrite(int)':
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:106: error: 'LOW' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:106: error: 'digitalWrite' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp: In member function 'void LCD4Bit_mod::print(int)':
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:118: error: 'HIGH' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:118: error: 'digitalWrite' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:119: error: 'LOW' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp: In member function 'void LCD4Bit_mod::clear()':
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:139: error: 'delay' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp: In member function 'void LCD4Bit_mod::init()':
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:146: error: 'OUTPUT' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:146: error: 'pinMode' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:154: error: 'delay' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:160: error: 'delayMicroseconds' was not declared in this scope
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp: In member function 'void LCD4Bit_mod::leftScroll(int, int)':
/Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:225: error: 'delay' was not declared in this scope

All forums are advised to replace on file LCD4Bit_mod.cpp the line '#include "WConstants.h" on "#include "Arduino.h"'.
Alas, this does not lead to success.

It turns out that's what:
Quote
In file included from /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:191,
                 from /Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:29:
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:116: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, const char*)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:115: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const String&)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:117: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, char)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:116: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const char*)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:118: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:117: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, char)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:119: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:118: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:120: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:119: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, int)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:121: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:120: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:122: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long unsigned int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:121: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, long int)' here
In file included from /Users/ogogon/Documents/Arduino/libraries/LCD4Bit_mod/LCD4Bit_mod.cpp:29:
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:195: error: declaration of C function 'uint16_t makeWord(byte, byte)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:194: error: previous declaration 'uint16_t makeWord(uint16_t)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:205: error: declaration of C function 'long int random(long int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:504: error: previous declaration 'long int random()' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:206: error: declaration of C function 'long int random(long int, long int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:205: error: previous declaration 'long int random(long int)' here

How can I overcome this problem?

Ogogon.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have had the same troubles.  i went back to 0.23 and use that.  the problem being the developer of the board needs to redo the library.
Logged

St.-Petersburg, Russia
Offline Offline
Newbie
*
Karma: 1
Posts: 6
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

BTW, standard LiquidCrystal library provide 4-bit support since ArduinoIDE 0016.

So, there are no reasons to use old LCD4BIT code except unless you avoid changing the sketch for some reason. The better choise is to spend little time to transition from this unsupported library to LiquidCrystal (that is a part of Arduino IDE distro).
Logged

Offline Offline
Edison Member
*
Karma: 9
Posts: 1015
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I agree with Ilya V. Danilov above this message.

What happened is that the download code is not compatible with Arduino 1.0.
If it was just a sketch, removing the includes from the source would probably be enough.
But since you use it as a library, the includes have to be according to Arduino 1.0.
Logged

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 9
Posts: 1991
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Dump that gawd-awful LCD4bit library.  The standard LiquidCrystal library is vastly superior.  The developer probably gave up on it once the standard library did 4 bits (and better) years ago. I've been playing with Arduino for around 3 & a half years and the standard LiquidCrystal library has done 4 bits for most of that time.
Logged


Sweden
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Found a solution!

This works with Arduino 1.0.1 and the 2x16 LCD/keypad.

http://www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009)

Look at the second example, using LiquidCrystal.h

I just pasted the code, and added 
#include <LiquidCrystal.h>

at the top, and "tadaaaa"!

KR
Magnus
Logged

Stockholm
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you're using "1602 LCD and 6 AD buttons" shield from ITeadStudio, then you need to change default pins. Below code works for me smiley
from
Code:
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I´m using the Arduino 1.0.3.
I downloaded the library in: C:\Program Files (x86)\arduino-1.0.3\libraries\LCD4Bit_mod
In file LCD4Bit_mod.cpp I modified:

#include "LCD4Bit_mod.h"
#include "Arduino.h"
extern "C" {
  #include <stdio.h>  //not needed yet
  #include <string.h> //needed for strlen()
  #include <inttypes.h>
//  #include "WConstants.h"  //all things wiring / arduino
}

and...It works fine.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I´m using the Arduino 1.0.3.
I downloaded the library in: C:\Program Files (x86)\arduino-1.0.3\libraries\LCD4Bit_mod
In file LCD4Bit_mod.cpp I modified:

#include "LCD4Bit_mod.h"
#include "Arduino.h"
extern "C" {
  #include <stdio.h>  //not needed yet
  #include <string.h> //needed for strlen()
  #include <inttypes.h>
//  #include "WConstants.h"  //all things wiring / arduino
}

and...It works fine.

Tested it on Mac OSX, Arduino 1.0.4, and it worked fine.

Also tested this (from http://www.dfrobot.com/wiki/index.php/Arduino_LCD_KeyPad_Shield_%28SKU:_DFR0009%29) and it worked too:
Code:
//Sample using LiquidCrystal library
#include <LiquidCrystal.h>
 
/*******************************************************
 
This program will test the LCD panel and the buttons
Mark Bramwell, July 2010
 
********************************************************/
 
// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
 
// define some values used by the panel and buttons
int lcd_key     = 0;
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5
 
// read the buttons
int read_LCD_buttons()
{
 adc_key_in = analogRead(0);      // read the value from the sensor
 // my buttons when read are centered at these valies: 0, 144, 329, 504, 741
 // we add approx 50 to those values and check to see if we are close
 if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
 if (adc_key_in < 50)   return btnRIGHT;
 if (adc_key_in < 195)  return btnUP;
 if (adc_key_in < 380)  return btnDOWN;
 if (adc_key_in < 555)  return btnLEFT;
 if (adc_key_in < 790)  return btnSELECT; 
 return btnNONE;  // when all others fail, return this...
}
 
void setup()
{
 lcd.begin(16, 2);              // start the library
 lcd.setCursor(0,0);
 lcd.print("Push the buttons"); // print a simple message
}
 
void loop()
{
 lcd.setCursor(9,1);            // move cursor to second line "1" and 9 spaces over
 lcd.print(millis()/1000);      // display seconds elapsed since power-up
 
 
 lcd.setCursor(0,1);            // move to the begining of the second line
 lcd_key = read_LCD_buttons();  // read the buttons
 
 switch (lcd_key)               // depending on which button was pushed, we perform an action
 {
   case btnRIGHT:
     {
     lcd.print("RIGHT ");
     break;
     }
   case btnLEFT:
     {
     lcd.print("LEFT   ");
     break;
     }
   case btnUP:
     {
     lcd.print("UP    ");
     break;
     }
   case btnDOWN:
     {
     lcd.print("DOWN  ");
     break;
     }
   case btnSELECT:
     {
     lcd.print("SELECT");
     break;
     }
     case btnNONE:
     {
     lcd.print("NONE  ");
     break;
     }
 }
 
}

If you still have a problem displaying info on the screen, be sure to check the LCD contrast!
Logged

Pages: [1]   Go Up
Jump to: