Problem with HD44780 LCD

So I just ordered an Arduino and a HD44780 LCD from sparkfun electronics. I had it up and running with the blinking LED in a few minutes. Now my problem is the LCD.

I don't think it as as much of a hardware problem as software. Here is the tutorial I am using

I already know this is outdated because it refers to the wrong location for the libraries, but it is still not working with them in the correct place.

Here is the error I get. Can anyone help me with this?

LiquidCrystal.cpp:8: error: declaration of C function 'void pinMode(int, int)' conflicts with
D:\Documents and Settings\Paul\My Documents\arduino-0010\hardware\cores\arduino/wiring.h:74: error: previous declaration 'void pinMode(uint8_t, uint8_t)' here
LiquidCrystal.cpp:9: error: declaration of C function 'void digitalWrite(int, int)' conflicts with
D:\Documents and Settings\Paul\My Documents\arduino-0010\hardware\cores\arduino/wiring.h:75: error: previous declaration 'void digitalWrite(uint8_t, uint8_t)' here
LiquidCrystal.cpp:10: error: declaration of C function 'int digitalRead(int)' conflicts with
D:\Documents and Settings\Paul\My Documents\arduino-0010\hardware\cores\arduino/wiring.h:76: error: previous declaration 'int digitalRead(uint8_t)' here
o: In function `__static_initialization_and_destruction_0':
undefined reference to `LiquidCrystal::LiquidCrystal()'o: In function `setup':

In liquidcrystal.cpp, try removing the following lines:

  extern void pinMode(int, int);
  extern void digitalWrite(int, int);
  extern int digitalRead(int);
  extern void portMode(uint8_t, uint8_t);
  extern void portWrite(uint8_t, uint8_t);
  extern uint8_t portRead(uint8_t);

in version 010 these functions are defined wiring.h and have different parameters, which is what causes the error message.

I use the similar 4bit LCD library and notice that that does not have (or need) the above definitions.

So if I got straight to the 4bit I should be fine?

It works very for me :slight_smile:

Have you installed the 4bit library to see if it compiles in your environment?

I got mine to compile by changing 'int' in the lines you showed to 'uint8_t' - haven't tested on hardware though.

I got mine to compile by changing 'int' in the lines you showed to 'uint8_t' - haven't tested on hardware though.

That should work but it has a disadvantage that you may not be aware of. If in some new arduino release, any of those extern function prototypes change you will get compile errors again.

For example, if portRead, portWrite, or portMode function definitions changed in a future release of arduino, a version of the lcd library with the externs declared as they are now would have compile errors but a version with them removed would compile and run perfectly.

It has been my experience that external declarations in a source file create an avoidable maintenance burden.

;D

I got it working with 4 bits!

My problem is that my LCD doesn't seem to automatically go to the next line. Is there some kind of code I am missing for this?

I don't think there is code in the library to do that. You could add it to the library by writing some code to keep track of the cursor position and the length of strings that are written to the LCD. But then you may want to prevent words from wrapping in the middle and it gets a little complicated. It may be easier to do the formatting you want in your sketch.

good to hear you have it working :slight_smile:

My problem is that my LCD doesn't seem to automatically go to the next line. Is there some kind of code I am missing for this?

Thats because for some stupid reason, the LCD's memory is mapped weirdly.

I'll probably make a nice neat library eventually which handles that and stuff like custom characters.

I'll probably make a nice neat library eventually which handles that

That would be useful, particularly for those single line displays that has the 9th character starting at address 0x40 :o

I recently bought a box of red LCD displays in a flea market, they are one line 16 character displays, but i have to set them up as though they are two lines of 8 characters to make them work.

I recently bought a box of red LCD displays in a flea market, they are one line 16 character displays, but i have to set them up as though they are two lines of 8 characters to make them work.

MikMo, they are addressed as two lines of 8 characters. Did you modify the library to allow them to be treated as if one line of 16 chars?

If you have coded the cursor tracking functionality necessary to make this work alongside cursorTo type calls then would you have any objection to posting the code.

I have not modified the lib. I tried the "standard" lib. first without much luck, then i used the 4bit lib. and just initializes the display as a two line display.

I think i had to change a few declarations in the 4 bit lib. to make it compile. Some integer datatypes if i remember corectly.

So now i have a whole lot of 16 char. red on black background displays, that actually work.

I have not modified the lib. I tried the "standard" lib. first without much luck, then i used the 4bit lib. and just initializes the display as a two line display.

I'm not sure why but when I got my first LCDs the libraries there werent any good either.
Maybe they should be removed and a new one made?

My problem is that my LCD doesn't seem to automatically go to the next line. Is there some kind of code I am missing for this?

Thats because for some stupid reason, the LCD's memory is mapped weirdly.

I'll probably make a nice neat library eventually which handles that and stuff like custom characters.

This is the LCD I am using:

I read another person on this forum had the same 1 line problem with it but he never fixed it as far as I know.

So I have gotten it to go to the second line, but not on demand. It will just wrap around whenever it feels like it. I noticed in the inatialiing code there is a bit that in the comments says it makes the LCD 1-line, anyone know how I would change this to two lines?

///////////////////////////////////////////////////// 4 pin initialization
LcdCommandWrite(0x03); // function set:
// 4 pin initialization
delay(64);
LcdCommandWrite(0x03); // function set:
// 4 pin initialization
delay(50);
LcdCommandWrite(0x03); // function set:
// 4 pin initialization
delay(50);
LcdCommandWrite(0x02); // function set:
// 4 pin initialization
delay(50);
LcdCommandWrite(0x2C); // function set:
// 4-bit interface, 1 display lines, 5x7 font
///////////////////////////////////////////////////// end of 4 pin initialization

I'm having the same problem.

If i setup the LCD in 4 lines, the LCD keep in one line mode.
If i setup in 2 lines give me 2 lines, now what i musto do to have the 4 lines?

I'm think in the C++ code of the libray you have some IF's testing only 1 or 2 lines and not more!!

Some way to fix it?

My LCD is a WINSTAR WH2004

Best Regards
Frank

I have the same LCD and i need to know how to connect it to an Arduino Duemilanove

Information about LCDs is here, on the Playground:

http://www.arduino.cc/playground/Code/LCD

You'll need the data sheet for your LCD, one that gives the pinout of the connector (usually 14 or 16 pins, either in a single row or two rows).