1602 I2C is not showing

Hi! I bought noname LCD with noname I2C, connected it to my UNO R3 (A4 - SDA, A5 - SCL) and used this sketch:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>



#define BACKLIGHT_PIN     13

LiquidCrystal_I2C lcd(0x27);  // 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
  pinMode ( BACKLIGHT_PIN, OUTPUT );
  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);
}

But it doesn't work correctly. Display blinks, but text not printed. How to solve this problem?

There are several things to be addressed.

Normally the I2C adapter is soldered directly to the LCD. In your case you are using a breadboard but it looks like you have not soldered the pins to your devices.

After applying power but before running any program you should see a line of blocks on your display. You may have to adjust the contrast potentiometer (it's blue) to make them visible.

You also should use a reliable I2C library. The only recommended library at this point is the one by F Malpartida which you can find here --> https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

I would also suggest a simpler program to start, one that does not use anything fancy such as custom characters and one that does not do anything in loop().

Don

Thanks for this. I've been banging my head against a brick wall trying to get LCD displays working on the ATMega2560. Now, thanks to your comment about the best library, I can control 16x2 and 20x4 displays with ease.

Now to get on with my BNO055.

W

Notice floresta's first remark ?
You absolutely need to solder the pins to the boards.

floresta:
Normally the I2C adapter is soldered directly to the LCD. In your case you are using a breadboard but it looks like you have not soldered the pins to your devices.

Fatal error!

floresta:
After applying power but before running any program you should see a line of blocks on your display. You may have to adjust the contrast potentiometer (it's blue) to make them visible.

Well, if you have it connected with flying leads, just disconnect SDA and SCL, re-start it as such (by connecting the power to the Arduino which you had disconnected to make changes) and adjust the contrast potentiometer to see the blocks. Then re-connect SDA and SCL.

Of course you only do this once you have properly soldered the pins to the display.

floresta:
You also should use a reliable I2C library. The only recommended library at this point is the one by F Malpartida which you can find here --> https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

And remove completely the original LiquidCrystal library.

floresta:
I would also suggest a simpler program to start, one that does not use anything fancy such as custom characters and one that does not do anything in loop().

Actually, the very first thing to do, is to use the i2cLCDguesser sketch to determine the correct "descriptor" for your module and use that descriptor in all your sketches, not the incomplete and useless:

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

Paul__B:
Actually, the very first thing to do, is to use the i2cLCDguesser sketch to determine the correct "descriptor" for your module and use that descriptor in all your sketches, not the incomplete and useless:

Thanks! That's great sketch!
It generates next: lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); and it works!

rodionov12:
Thanks! That's great sketch!
It generates next: lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); and it works!

Well, don't blame me, I didn't write it!