Problem with getting text correctly on LCD 1602 [SOLVED]

Hello, I got some problems with a LCD display I am using.
If I am adding too long text it will show blank, but if I add 4 or less letters it will be shown, but more then everything disappears.
It can show as much numbers as I want like I can print over 100 numbers and it will still be visible.

tutorial code I used, this one should print "Hello, World!" and time since the program started (this part also fails, it shows random letters instead):

/*
  LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD
 and shows the time.

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(2,3,4,5,6,7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}

In this modifyed tutorial code, I changed "Hello, World!" with numbers, all numbers within the screen was visible and the counter also worked fine:

/*
  LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD
 and shows the time.

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(2,3,4,5,6,7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("123456789123456789123456789123456789123456789123456789123456789123456789");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}

Image where I try "Hello, World!" and the counter:

Image where I try with numbers, same setup as image above:

I have tried different wiring setups and different codes and a existing code I used years ago on another arduino project (it worked on that LCD) with no luck.

We get this question every so often! :grinning:

This is a two line display, not a computer terminal.

It has a certain number of positions on the display, mapped to a - usually - slightly larger array of RAM bytes on the HD44780 equivalent chip.

Your business is to write characters to the limited number of positions on the display. You almost always use a library to do this. If you feed into that library function, more characters as data, than there are positions on each display line, you get "pot luck" on where the extra characters get put. If it does not do what you think it should when you feed too much data, then that is just tough. :astonished:

And you are using a really old library. Bill Perry's "HD44780" library is now available to be installed from the library manager in the IDE and contains plenty of tutorials and examples when you install it, and will generally behave much more predictably than the old library.

Tried what you said, changed to Bill Perry's "HD44780" still no luck, I did not modify any code except the pin locations, by some weird reasons some few examples worked, but the simplest one with "Hello World" did not work it worked when I removed mostly all letters with, like my original problem was.

Edit:
I noticed now it is the letter "o" and "O" that breakes the text on the LCD, idk why. Is there a way to fix this?

It would help if you could provide...

  • some examples of specific messages that appear correctly
  • some examples of specific messages that do not appear correctly along with a picture of what does appear

also, those of us with elderly eyes would appreciate...

  • larger pictures
  • pictures that are oriented correctly
  • pictures that have adequate light so that the wiring can be followed

When you send lots of characters at once it is fairly easy to determine which characters will appear and which will not. For 16x2 display starting at the top left the first 16 will appear, the next 24 will not, the next 16 will appear on the second row, the next 24 will not.

For a complete explanation follow the LCD Addressing link at Don's Collected Technical Information.

Don

I noticed now it is the letter "o" and "O" that breakes the text on the LCD, idk why. Is there a way to fix this?

What do you mean by "breakes(sic) the text"? Give a specific example as mentioned above.

Don

floresta:
What do you mean by "breakes(sic) the text"? Give a specific example as mentioned above.

Don

Well when it contains the letter "o" and/or "O" the text disappears and gets replaced with squares all over the upper part of the scrreen, if I remove "o" and/or "O", the text is visible and shown as normal.
An example of what you can try print is "Hello" and it will return just squares.
If you replace "o" with "0" (zero) like "Hell0" it will show a expected result.

I went over the wiring many times. And those squares is what you normally would get if you adjust the potensiometer that is connected. The picture resolution is actually not far from 4k, I don't know how to make them bigger here.

Edit:

This is with "Hello there!"

And this is with "Hell0 there!"

Sorry, you cannot practically use googleusercontent links to post pictures!

At minimum, you can upload the picture as an attachment, then use the attachment URL to embed the picture into your posting proper. It is the case that attachments are not very useful/ extremely unhelpful to people using tablets to view the forums.

I went over the wiring many times.

Until you figure out how to take and post a usable picture we will not be able to verify your wiring.

Don

How to post images.

pictures added




Your last picture is the only one that shows almost your entire setup. It reveals that you have the type of solderless breadboard with non-continuous power rails.

The red and blue lines alongside the power rails have gaps in them near the number '30'. The corresponding power rails also have gaps at those points.

This means that the GND connection from your Arduino is effectively not connected to your display. I'm surprised that it functions as well as it does.

Don

floresta:
Your last picture is the only one that shows almost your entire setup. It reveals that you have the type of solderless breadboard with non-continuous power rails.

The red and blue lines alongside the power rails have gaps in them near the number '30'. The corresponding power rails also have gaps at those points.

This means that the GND connection from your Arduino is effectively not connected to your display. I'm surprised that it functions as well as it does.

Don

Ah so that is why my clock module and the ultrasonic sensor was not working, moved the GND and it actually fixed the characters. Didn't notice that gap on the red and blue lines, it's my first time on many years that I started using Arduino again so didn't remember that. Well that fixed the problem for everything I got problems with (those other problems appeared just today, they are fixed as well).

Thanks for noticing that, I have marked the thread as solved.