16x4 LCD Display

Questions, answers, feedback or just general conversation about anything to do with the store 'Hacker's Warehouse'.

16x4 LCD Display

Postby dr3x » Thu Aug 30, 2012 11:21 pm

The offsets are wrong in the standard Arduino library; this change worked for me:

Code: Select all
void LiquidCrystal::setCursor(uint8_t col, uint8_t row)
  //int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
   int row_offsets[] = { 0x00, 0x40, 0x10, 0x50 };
  if ( row >= _numlines ) {
    row = _numlines-1;    // we count rows starting w/0
  command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
Posts: 2
Joined: Sun Aug 26, 2012 5:58 pm

Re: 16x4 LCD Display

Postby Tim Laren » Fri Aug 31, 2012 10:34 pm

You are assuming that the display is 16 characters.
They come in 1 line thru 4 lines (well 1,2 and 4). They also come in 8, 10, 16, 20, 40 and 80 characters per line.
The most common is 1, 2 and 4 lines and 16 and 20 characters per line.
The library never saves the characters per line of the display.
That array should be calculated based on number of characters per line.
I will find my modified library where I added _charline and used it to calculate the array you redefined.

They way a 4 line display works is the third line is actually end of the first line. If you set the cursor at 0,0 and start printing you will see after the last character on the first like you will start at the first character of the third line.

All this is from memory and I currently do not have one here setup and connected, but I will as soon as I have some time.

Let me know if this makes sense or not.

Thanks for the input.
Tim Laren
Site Admin
Posts: 137
Joined: Thu Mar 04, 2010 8:25 pm

Re: 16x4 LCD Display

Postby dr3x » Sat Sep 01, 2012 11:11 am

Yes I should have mentioned this is a quick fix for the 16x4 LCD I had, may not work for other LCDs.

The better fix would be as you suggested to set the offsets based on the initial parameters of columns and lines but I don't know all the possible configurations.

Thanks for the additional info.
Posts: 2
Joined: Sun Aug 26, 2012 5:58 pm

16x4 LCD Display

Postby Adam41kgance » Sat Sep 22, 2018 12:44 am

Have you set up the circuit and tested any of your code?

If not then that is what I would do...

noting like the instant feedback of seeing the minor changes to your code and the effect on what is displayed on the LCD.
Posts: 3
Joined: Wed Sep 05, 2018 8:21 am
Location: USA

Return to Hacker's Warehouse Feedback

Who is online

Users browsing this forum: No registered users and 1 guest