I am using the following codes to print characters on LCD display....

#include <LiquidCrystal.h>

const int rs = 8, en = 9, d0 = 4, d1 = 5, d2 = 6, d3 = 7;
LiquidCrystal lcd(rs, en, d0, d1, d2, d3);

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

void loop() {
  if (Serial.available()) {
    while (Serial.available() > 0) {

but in the end it is generating an unwanted character also.. enter image description here

kindly help me with the problem

  • I guess, it is the newline character. What line end is Serial Monitor set to send? – Juraj Nov 25 '18 at 8:44
  • Does 'lcd.write("Hello");' work? You should check if the problem is on the serial or on the LCD. – Paul Nov 25 '18 at 9:40
  • yes it works perfectly – Gyan_mishra Nov 25 '18 at 10:42
  • @Gyan_mishra in that case, it doesn't appear to be a problem on the display's side. Is the same character generated when you do: "lcd.write("\r\n");"? Or choose "No line ending" in the Arduino serial monitor. – Paul Nov 25 '18 at 11:07
  • thanks for help @Paul .... the problem was exactly the same... – Gyan_mishra Nov 26 '18 at 7:52

The character to the right of the 'A' on your LCD display does not correspond to any of the built-in character bitmap definitions (either on a EU or Chinese display). This random pattern is likely one of the 8 programmable character bitmaps supported by the LCD that has not been defined yet (ASCII codes 0 to 7).

So, you're likely sending the LCD a character with a value between 0 and 7. It's probably a good idea to filter out invalid characters before attempting to display them on your LCD.

Filtering Example:

char c = Serial.read();
if ((c >= 32) && (c <= 128))
  • could you tell me, how to filter out invalid characters before attempting to display – Gyan_mishra Nov 26 '18 at 7:56
  • I've updated the answer to illustrate a simple filtering example. Take a look at an ASCII table to understand why the numbers I chose are significant. – Jeff Wahaus Nov 26 '18 at 22:21
  • thank you @jeff, for providing me such an excellent example of filtering.. it worked – Gyan_mishra Nov 27 '18 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.