arduinolcd

How can I clear an LCD from my Arduino?


I'm using serial communication to display the the data to my 4x20 lcd display. When I filled up all the lines of course I need to clear it. I've search over the net and found something like:

Serial.write(27); // ESC command
Serial.print("[2J"); // clear screen command
Serial.write(27);
Serial.print("[H"); // cursor to home command

But it doesn't work. I also found a solution like Serial.println(); but that solution (cheat as they called it) will only work on a serial monitor. So is there any possible solution to clear the display or delete a single character from the LCD?


Solution

  • I found a quick solution for my problem

    for (int i=0; i < 80; i++) { Serial.write(8); // print 80 times forward (BS) }

    if you have larger display just increase the value of the loop. As my observation in the serial monitor The cursor pushes forward until the line is clear (based on your loop). but this will not allow you to delete a single character in your display.