Go Down

Topic: 20x4 LCD2004 I2C LCD Showing 2 solid lines (Read 1 time) previous topic - next topic


I just bought this lcd and when I hook it up it immediately displays two solid lines, and stays like that no matter what my program tells it to do.

Here is my code (default example):

Code: [Select]
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define BACKLIGHT_PIN     13

LiquidCrystal_I2C lcd(0x38);  // Set the LCD I2C address

//LiquidCrystal_I2C lcd(0x38, BACKLIGHT_PIN, POSITIVE);  // Set the LCD I2C address

// Creat a set of new characters
const uint8_t charBitmap[][8] = {
   { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
   { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
   { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
   { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
   { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
   { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
   { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
   { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }

void setup()
   int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));

  // Switch on the backlight
  digitalWrite ( BACKLIGHT_PIN, HIGH );
  lcd.begin(16,2);               // initialize the lcd

   for ( int i = 0; i < charBitmapSize; i++ )
      lcd.createChar ( i, (uint8_t *)charBitmap[i] );

  lcd.home ();                   // go home
  lcd.print("Hello, ARDUINO "); 
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print (" FORUM - fm   ");
  delay ( 1000 );

void loop()
   lcd.home ();
   // Do a little animation by writing to the same location
   for ( int i = 0; i < 2; i++ )
      for ( int j = 0; j < 16; j++ )
         lcd.print (char(random(7)));
      lcd.setCursor ( 0, 1 );
   delay (200);

Here is an image of my setup:


Are you sure of the address?  Find and use the !2C scanner program to make sure of the address.  Here is code for my LCD that works.

Code: [Select]
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR    0x3f  // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

Your lcd.begin is for a 16 char X 2 line display.

Nick Gammon

An I2C scanner on this page:



Seriously curious as to why Mr Gammon didn't mention this line of code... He, of all people should have picked this up in an instant.

Disclaimer: I've only a 1602, so can't test the code.

You question topic says you're using a 20x4 Lcd, right?
Well then, it seems rather odd that you would try to initialize it with the settings for a 1602, as you do in this line:

Code: [Select]
  lcd.begin(16,2);               // initialize the lcd

I'd be surprised if (as groundfungus alludes to) that wasn't supposed to be

Code: [Select]
  lcd.begin(20,4);               // initialize the lcd

Nick Gammon

Seriously curious as to why Mr Gammon didn't mention this line of code... He, of all people should have picked this up in an instant.

Well, I do tend to skim once I identify a problem area. However, well spotted. :)


Nick Gammon



Back to the poster's issue:  Contrast setting?  The 16,2 setting works on 20,4 displays, just only lights up rows 1 & 3, instead of 1&2, or 1,2,3&4....
"solid lines" sounds like he's only getting solid character blocks, with all bits at the same contrast level (whether on or off).


       Yes I've had the contrast problems. long ago when I was new to LCD's as 123 says it impossible to know what DOTS are on or off.
I am new to the Arduino and C so am struggling myself. I too want to try the i2c way with LCD's!  Just seen this on ebay and it looks like the answer: http://www.ebay.co.uk/itm/181193639379?ssPageName=STRK:MEWAX:IT&_trksid=p3984.m1423.l2648

Earlier this year I was playing with PIcaxe's and a not very good basic, still have a long way to go, but if you don't try you never know!  I don't see that defining the LCD as a 16x2 when it's a 20x4 would cause any problems! other then the text not being in the right place? Whereever that might be!!

Open your mind! But not too far, your brains might fall out.
Also like Photography, model building and my 300+ Cacti and Succs.

Go Up