4 bit LCD connection only uses half of LCD

Hello,

I am using neillzero's 4-bit LCD library with a 16x1 character LCD. After a little initial confusion with which wires went were, I am now able to write to the LCD.

However, only the first 8 character spaces are used. The second 8 are left blank, and my "hello world" is truncated to "hello wo". If I do an lcd.commandWrite(0x1C), everything shifts right, but it drops the last character, rather than shifting it into the 9th character space.

I have tried with 3 different LCDs of the same size, and they all exibit the same problem.

I suspect that I am either not initializing the LCD correctly, or I need to set a configuration setting that I've missed, but I don't know what it is.

If anyone else has seen this, or has any idea how to fix it, please let me know.

My program :

#include <LCD4Bit.h>

void setup()
{
  LCD4Bit lcd = LCD4Bit(1);
  lcd.init();
  delay(500);
  lcd.clear();
  delay(500);
  lcd.printIn("hello world");
  delay(500);
  lcd.commandWrite(0x1c);
  delay(500);
}

void loop()
{
}

I have it figured out. The LCD is 16x1 physically, but it is 2x40 logically. If I write a message that is greater than 40 characters, the part beyond 40 characters appears on the second set of 8 character spaces.

As a result, the way to get a message onto the display is to break it into two 8-character parts, put the cursor at the first character of the first line, print the first part of the message, move the cursor to the second line, and print the second part of the message.

The code I used for this is below.

Interestingly, since there are 2 lines of 40 chars, and the LCD only uses 8 on each line, there are 64 characters that are not visible. These are probably good for buffering for scrolling, or just as off-chip storage. You would have to be able to read from the LCD to use it as off-chip RAM.

void setup()
{
  LCD4Bit lcd = LCD4Bit(2);   //It's 2-line internally
  lcd.init();
  delay(50);
  lcd.clear();
  delay(50);
  lcd.cursorTo(1,0);        //Home on first line
  delay(50);
  lcd.printIn("hello wo");  //First part of message
  delay(50);                
  lcd.cursorTo(2,0);        //Home on second line
  delay(50);
  lcd.printIn("rld! foo");  //Second part of message
  delay(50);
}

Pretty weird.

I guess you might want to make some custom routines which split and position your string without you having to think about it. That is, if the problem really can't be solved just by some initialisation specific to your device.

What LCD display are you using? Got a link to the datasheet?

Did you ever try the display with the standard 8-bit Arduino LCD library? It'd be good to know the same behaviour is exhibited there.

Also, please let me know what I can do to improve the "getting started" experience with the 4-bit library. You mention you had some wiring problems. Feel free to add explanation to the 4-bit LCD library wiki page.

neill

Hey guys,

I know this is an old thread but I'm having exactly the same issue, 1 line display that shows first 8 chars on line 1 and then next 8 at postion 40... not much fun!

Did anyone ever work this out it must be an init setting, my LCD is part of a kit from maplin and did work as a 16 char display in that project (do not have the code for this :frowning: ) Model is GDM1601C

Thanks for any heko you can give,

G

Hi tony,

Did anyone ever work this out it must be an init setting...

No sorry, this is just the way the manufacturer designed his hardware.
The address where the individual lines of different LCD's start is usually mentioned in the datasheet for the LCD-controller.
There is no standard for this, so you have to look it up once you decided on the type of LCD to use.
(Very annoying to someone who wants to create a library for LCD's !)

Eberhard
.

OK thanks for such a quick reply!

I got this from an old kit I had so no real loss, I wanted a 2 line eventually anyhow. So ill make sure I read the datasheet before I buy.

Cheers

G

Same issue, using the latest LCD library that comes with 017.

My little 16x1 display shows the first 8 chars of a string in the first 8 columns then characters in positions 41-48 of the string display in the last 8 columns of my display.

LCD brand name "Truly m161-1a1"
other markings
MTC-C161DPRN-1N D0444
TR-804
and happily passed QC by no.19

Most 16 by 1 LCD's work like 8 by 2, so if you consideer it two lines of 8 chars it probably works.

The reason they act like this is so that the same chip can be used in lots of different LCD configurations.
It is just something you are going to have to live with, that's like or at least electronics.

Most 16 by 1 LCD's work like 8 by 2 ...

The reason they act like this is so that the same chip can be used in lots of different LCD configurations.

You can find more information about both of these statements if you follow the LCD Addressing link at http://web.alfredstate.edu/weimandn.

Don

That was a real aha experience reading that page.

Thanks

MikMo

had the same issue but this fixed it.
displays 1234567890123456 on the lcd.

#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // this is obiusly my connection since i use a ethernet shield i can't use 10..13
// LiquidCrystal lcd(12, 11, 5, 4, 3, 2); normal connections

void setup(){
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print("12345678");
  lcd.setCursor(0, 1);
  lcd.print("90123456");
}

void loop(){
}

if someone has a function for spliting it automaticly please tell me would be much easier to code my robot

i'm currently using it to display battery level :smiley: works like a charm!
it would be much easier if its 1 line :stuck_out_tongue: or something

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1264823411