Garbled characters using lcd.println

In the middle of a complicated project I started having problems with garbled LCD characters. I updated the library (the one I had was 10 years old) and started reducing the code thinking something else was causing the problem... until I was with almost no code :slight_smile:

Than I uninstalled and reinstalled the compiler and still ... no change.

Indeed I didn't usually use lcd.println() but since a week ago I thought I could save one lcd.setCursor() line of code. Bad idea. But I used it for some days without problems, well, it was eventually outside the 20 characters line limit, appearing in the next line but was being overwritten by the line text that follows.

I can't find out why this code writes TEST immediately followed by two garbled characters. Is lcd.println() trying to print the terminator?

If I use lcd.print() it is OK.

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

LiquidCrystal_I2C lcd(0x3F,20,4);

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

void loop() {
    lcd.clear();
    lcd.println("TEST");  // **NOTE** if I replace lcd.println() by lcd.print() there is no problem
    while(true){}  // stay forever 
}

Thank you
Martins

Println adds a CR and LF. Apparently they show up as garbled characters on your LCD.

You're right... makes sense (shouldn't). I tested another 20x4 and it behaves the same.

Thank you.
Martins

The character set of the LCD is not, entirely, the same as ASCII. 0x10 (LF) and 0x13 (CR) are different characters on the LCD.

The println() function is not supported by the liquidCrystal libraries. You can enable line feeds in the hd44780 library for LCDs.

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