Hello!
I've just connected my 16x4 LCD to Arduino board.
I can print to it, but I have problem with 3rd and 4th lines of LCD - the message is printed on those lines starting from 5th character.
void setup() {
// set up the LCD's number of rows and columns:
lcd.begin(16, 4);
// Print a message to the LCD.
lcd.setCursor(0, 3);
lcd.print("hello, world!");
}
If I set cursor like this lcd.setCursor(-4, 3); it's working properly.
Why is it doing this? Is there is a way to solve it?
This has come up at least once before since the improved LiquidCrystal library was released. It is because the library treats all 4-line displays the same with respect to the starting address for each line. The problem is that the 16x4 has different starting addresses for lines 3 and 4 than the 20x4 for which the library is written.
Is there is a way to solve it?
Your method will work until the library is updated. You could go into the LiquidCrystal.cpp file and edit the setCursor routine.
Changing: int row_offsets[] = { 0x00, 0x40, 0x14, 0x50 }; to: int row_offsets[] = { 0x00, 0x40, 0x10, 0x54 }; would probably do the trick. Of course the 20x4 displays would now be messed up!
If you want to read about the reason for the curious addressing scheme for these LCD displays then check out http://web.alfredstate.edu/weimandn, use the link to LCD Addressing.
... will see if I can get my source code to the maintainer(s)
Do you (or does anyone else) know the proper way to do this? On the Arduino home page it says:
Development: For information on the development of Arduino, see the Arduino project on Google Code. Changes to the software are discussed on the developers mailing list.
I tried communicating to them via the provided link and got a nastygram in response. It appears that the 'software' mentioned is limited to the IDE which does not include the libraries, even the official ones that come with the IDE.
I have some corrections to the comments and a change in the initialization that I feel should be implemented even though the current code seems to work reliably.
If you want some background information on the reasons behind this strange LCD behavior take a look at the LCD Addressing link at http://web.alfredstate.edu/weimandn.