Lcd printing 2 glitched letters

Hi, im trying to print a random phrase on a display via bluetooth using a Arduino mega, hc-05, a display 16x2 attached with a PCF8574 microcontroller. But everytime time i try to send a phrase, the lcd prints 2 extra glitched letters. On serial monitor it is printing the phrase normally. Here is my code

#include <LiquidCrystal_PCF8574.h>
#include <Wire.h>
#include <SoftwareSerial.h>

SoftwareSerial bluetooth(18, 19);
LiquidCrystal_PCF8574 lcd(0x27);
char b;
String a;

void setup() {
  lcd.begin(16, 2);

void loop() {
   while (Serial1.available()) {
   b =;
   a += b;

@johnnykujo Why do users choose to ignore the advice on posting code ?

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here to make it easier to read and copy for examination

If you get errors when compiling please copy them from the IDE using the "Copy error messages" button and paste the clipboard here in code tags

1 Like

What have you got Line ending set to in the Serial monitor ? Is it "Both LN & CR" by any chance ?

1 Like

Exactly right. This is very likely to be a CR LF issue.
char are just numbers, so you could filter our decimal values or 10 and 13 (cr and lf) or simply anything below 32.

The serial monitor showed "abcd" normally, i make some research and i found that the Serial monitor uses CR and LF normally, but the lcd doesn't have such configuration. But still i don't know how to add this do the lcd

Take a view here.

1 Like