arduino / arduino/ArduinoCore-avr

Leonardo/32U4: Serial Monitor affects LiquidCrystal display output

Open
#434 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Hi,

so I have a Leonardo + a 2004 HD44780 based LCD display connected to the pins you can see in the code snippet.
I'm using platformIO + the latest Arduino core + the latest LiquidCrystal library version.

This code will add one additional zero to the string it should print ("0.0000"). So the display actually shows "0.00000".
This only happens after 10 seconds, when the delayMillis counter is up and the serial monitor starts being spammed and therefore it is being written to the LCD and to the serial monitor simultaniously. This actually also happens with way less frequent spamming, but this example showed to reproduce the issue reliably.

If the serial monitor is not connected, the issue does not arise.

Probably this is somehow related to the fact that the LCD library inherits print and there's some buffer whoopsie happening somewehere?

I think, this is a legit bug.

```
#include
#include

#define LCD_RS_PIN 4
#define LCD_EN_PIN 30
#define LCD_DB0_PIN 12
#define LCD_DB1_PIN 6
#define LCD_DB2_PIN 8
#define LCD_DB3_PIN 9
#define LCD_DB4_PIN 10
#define LCD_DB5_PIN 5
#define LCD_DB6_PIN 13
#define LCD_DB7_PIN 21

#define ENC_A_PIN 7
#define ENC_B_PIN 23
#define ENC_BTN_PIN 22

LiquidCrystal LCD(LCD_RS_PIN, LCD_EN_PIN, LCD_DB0_PIN, LCD_DB1_PIN, LCD_DB2_PIN, LCD_DB3_PIN,LCD_DB4_PIN, LCD_DB5_PIN, LCD_DB6_PIN, LCD_DB7_PIN);

uint32_t heartbeatMillis = 0;
uint32_t delayMillis = 0;

void setup()
{
LCD.begin(20, 4);
LCD.clear();
}

void loop()
{
if (millis() - heartbeatMillis > 600)
{
LCD.setCursor(12, 3);
LCD.print("0.0000");



heartbeatMillis = millis();
}

if (millis() - delayMillis > 10000)
{
Serial.println("Heartbeat");
}

}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the provided Leonardo sketch with the LiquidCrystal display and serial monitor, checking the output before and after the 10-second serial-print condition. Then inspect the LiquidCrystal Print path and Serial output path to determine why concurrent writes alter the LCD text. Done means the display consistently shows "0.0000" while serial output continues.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, c
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.