Garbled LCD on arduino Uno

Hi, I have been stuck on this for hours and can't seem to get why my LCD is printing garbled texts even with the most basics of code/setup. I'm using an Arduino Uno with a 16x2 LCD which are connected without a potentiometer as that was one of the requirements given to me. My Pin connections are shown in the image below together with the basic code I am using to test the LCD.


My setup.

What I followed.

#include <LiquidCrystal.h> 
int Contrast=60;
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 
 void setup()
 {
  lcd.begin(16, 2);
    analogWrite(6,Contrast);
          lcd.setCursor(0, 0);
     lcd.print("HELLO");
 } 
     void loop()
 {

}

Code I used to test LCD.

Douple check the wiring or make an investment to get I²C interface for the LCD.

Thanks, but I have already checked the wiring multiple times, changed breadboards,wires and for my current project as much as I would like to, I'm not allowed to use an I²C interface.

Try moving the contrast control to a PWM pin that is not adjacent to the data pin. As a quick test, I would just move the analogWrite() to the end of setup, to see if the text gets sent to the display correctly without the PWM signal being active. It seems odd that the correct number of characters are displayed, and the text is printed on the wrong line, yet the display appears to have been initialized correctly.

I have moved the analog write to the the end of setup and changed the contrast control pin to 8 instead of 6 which is has no data pin beside it. This however, does not change the LCD display, it is still the same as shown in the images above. I do agree that it seems odd as having just tested the LCD to display numbers, surprisingly it can display numbers but not characters.

Still think it must be either wiring or a faulty display, because it works fine here.

(With a Nano I have at hand, but that should be irrelevant).

The display has been tested to work fine on another Uno board with the same wiring configuration. For the case of wiring do you perhaps have any specific wire connections that might be causing this issue? As I have even tested the wires with a multimeter and they all seem to be working as intended.

Change the data pins to different pins on the arduino and see if anything changes, you could just have a bad output on the atmega328.

1 Like

The only difference I can think of is that I have a 220 ohm resistor in the backlight circuit (LCD pins 15/16).

Thank you! You were spot on it seems the data pins I used initially were the issue!

You have posted in the UNO R4 Minima category of the forum. Is that actually the board that you are using ?

I moved your topic to a more appropriate forum category @i_eat_wires.

The UNO R4 WiFi category you chose is only used for discussions directly related to the UNO R4 WiFi board.

In the future, please take the time to pick the forum category that best suits the subject of your question. There is an "About the _____ category" topic at the top of each category that explains its purpose.

Thanks in advance for your cooperation.

It appears that there was an issue with the connections to LCD DB6 and DB7 pins.
For some reason whenever either one was supposed to be 1 the other pin would be set to high as well.
This caused a shift to other characters in the font table whenever either D7 or D3 of the byte was a 1 since it would cause the two upper bits of a nibble to set high.

i.e.
0x48 would turn in to 0xcc
0x45 would turn in to 0xc5
0x4c would turn into 0xcc
0x4f would turn into 0xcf

however
0x20 remains 0x20
0x31 remains 0x31
0x32 remains 0x32
0x33 remains 0x33

This explains why you saw odd Japanese characters for "HELLO" but not for " 123" as the "HELLO" characters were shifting to a different part of the font table but the " 123" was not.

Then the question becomes why?
It is odd because usually whenever there is some kind of short, a LOW beats out a HIGH in that if two signals are shorted and either one is low, both will be low.
In this case it is opposite.

Since it is working on another Arduino board,
I'm guessing either some kid of weird/bad wiring or a bad processor on the board that is not working.

--- bill

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.