(SOLVED) L2c display not showing text

I was trying to get the 16x2 text display working and the screen lights up, but there is no text. I already checked that my l2c is definitely 0x27 and I already adjusted the potentiometer.

Here is my code:

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

LiquidCrystal_I2C lcd(0x27, 20, 4);

void setup()
{
  lcd.init();
  lcd.backlight();
}


void loop()
{
  lcd.setCursor(1,0);
  lcd.print("hello");
  lcd.setCursor(1,1);
  lcd.print("123 123");
}

Shouldn’t there be an lcd.begin() in there somewhere ?

Hi,
No there shouldn’t. The LiquidCrystal_I2C library doesn’t use a “lcd.begin()”, only a “lcd.init()”.

Hi,
In the Hello_World example, there is two “lcd.init()”, one after another. Here is the example code:

//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Hello, world!");
  lcd.setCursor(2,1);
  lcd.print("Ywrobot Arduino!");
   lcd.setCursor(0,2);
  lcd.print("Arduino LCM IIC 2004");
   lcd.setCursor(2,3);
  lcd.print("Power By Ec-yuan!");
}


void loop()
{
}

Hi,
I just saw that at the beginning of your code, you have

Change that to

LiquidCrystal_I2C lcd(0x27, 16, 2);

There are several libraries with the name LiquidCrystal_I2C. The are not all the same and code from 1 may not run in another. Those LiquidCrystal_I2C are old and most are not maintaned. The newest and absolute best library for I2C LCD with the hd44780 controller (1602, 2004) is the hd44780 library by Bill Perry.

For an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.

To install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE menus, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.

The class that you want to use is the hd44780_I2Cexp class. There are examples to show how to use the library. The nice thing about the hd44780 library is that it will autodetect the I2C address and the I2C backpack to LCD pin mapping.

In the examples, there is a diagnostic sketch that will help us to help you if you still have trouble with the display. Run the diagnostic sketch and post the results.

Almost all of the LCD tutorials have the wiring of the contrast pot wrong. It is a mistake that has been perpetuated through the years. The right way is to wire the one end of the pot to ground and the wiper to LCD pin 3 (V0). The other end of the pot is left disconnected. So the pot is a variable resistor. Actually I find that a 1K fixed resistor from ground to Vo gives me satisfactory contrast on virtually every LCD that I have tried.

I tried using the library and the light showed up, but still no text.

Which Arduino board are you using?

Does adjusting the contrast have any effect?

Post the code that you tried.

Post a clear photo of your wiring.

Upload and run the diagnostic sketch. Copy the sketch output from serial monitor into a post. If I can’t help, the author of the library frequently uses the forum and can help.

I’m using Arduino Uno R3
Yes it does change the the contrast
The wiring is exactly like this:


And the code is just an example:


#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

hd44780_I2Cexp lcd;


const int LCD_COLS = 16;
const int LCD_ROWS = 2;

void setup()
{
int status;


	status = lcd.begin(LCD_COLS, LCD_ROWS);
	if(status) // non zero status means it was unsuccesful
	{
		hd44780::fatalError(status); // does not return
	}
 
	lcd.print("Hello, World!");
}

void loop() {}

The led doesn’t blink.
Also, where can I find the diagnostic sketch?

I know how the I2C display should be wired. I have been using them for years. What we need to see is how YOUR I2C display is wired and also to be able to examine the soldering. So photos of both sides of the display showing the soldering of the I2C backpack to the LCD and the soldering of the components on the I2C backpack can be valuable. We have solved others problems by looking at the photos. Try to make the photos clear and detailed.

Try a small init delay before the LCD.init something in the order of 15 mS
The datasheet specifies a startup delay , forget exactly what it is off top of head

You have not explained what you actually see.

What do you see on the display?

I just see the screen light up nothing else

Thank you! Soldering it fixed the issue!

OK, if you see nothing then you have not correctly set the contrast control. It will need to be set very near to one end due to the fault in the wiring (and the use of the wrong potentiometer value). When set correctly, you will see all solid blocks on the upper line only of the display (or you will actually see the correct text if the code and connections are correct).

We do of course assume that the connections from the display to the I2C “backpack” are actually soldered. :upside_down_face:

This topic was automatically closed after 120 days. New replies are no longer allowed.