0

So I have a standard 16x2 LCD display with 16 pins. The LCD display works fine with every other aspect, however, the "lcd.clear" function doesn't work with "Serial.begin(ANY BAUD)". I have tried changing bauds and downgrading the board software but it still doesn't work.

Basically, instead of clearing the display like it should do, it displays a weird character with 4 horizontal lines (in one character space) and then continues to write stuff after it.

Here is my code:

#include <LiquidCrystal.h> 
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); 
void setup() { 
 pinMode(8, INPUT);
 lcd.begin(16,2); 
 Serial.begin(9600);
}
void loop() { 
 lcd.print("incorrect"); 
 delay(3000); 
 lcd.clear(); 
 delay(100);
}

Whenever I delete the Serial.begin everything works fine, but when I add it the clear function doesn't work anymore.

So in this case, what happens is that the Arduino prints "incorrect", then instead of clearing the display, it prints out four horizontal lines, and then continues to print out "incorrect" infinitely.

VE7JRO
2,51519 gold badges27 silver badges29 bronze badges
asked Jul 9, 2019 at 3:40
1
  • You seem to use UART pins to connect your LCD. Commented Jul 9, 2019 at 10:50

2 Answers 2

1

Pins 0 and 1 are the hardware serial pins on the Mega. If you're going to use Serial, then you can't connect your LCD to those pins or it won't work. Even if you are only connected to Serial through the USB, pins 0 and 1 are still acting as Tx and Rx.

answered Jul 9, 2019 at 3:58
1
  • 1
    Can you please mark the answer as accepted. Commented Jul 9, 2019 at 4:42
0

Buddy you are using those pins which are used for communication purpose that is pin No. 0 and 1 is for RXD and TXD See the image you will observe what you are trying to do is wrong

answered Jul 10, 2019 at 0:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.