Trash characters on 16x2 display

The following code generates trash characters after the second print. I don't see why this is happening. Tried it with 2 different 16x2 displays. on an UNO.

#include <LCD_I2C.h>
int8_t secs = 45;
LCD_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(115200);
  delay(250);
  lcd.begin();
  lcd.backlight();
  lcd.clear();
  DisplayTime();
}

void loop() {}

void DisplayTime() {
  int8_t n;

  lcd.backlight();
  lcd.setCursor(11, 0);
  lcd.print(secs / 60);
  Serial.println(secs % 60);
  lcd.setCursor(11, 1);
  n = secs % 60;
  lcd.println(n);
}

Use lcd.print, not lcd.println, println prints a carriage return and newline character after the text, which cannot be properly displayed on an LCD.

1 Like

20x4?

20x4 is just one of the multiple displays I tried. All the others were 16x2 which is what I actually need.

Yes, it is the println that is causing the problem. Thank You!

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