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.

1
  • You seem to use UART pins to connect your LCD. 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.

2
  • Right thank you so much!
    – Leo Feng
    Jul 9, 2019 at 3:59
  • 1
    Can you please mark the answer as accepted.
    – Delta_G
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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