lcd.clear() throwing display/code out of sync?

I have an RSS feed being displayed on my LCD. This works fine as long as I don’t use lcd.clear() to clean the screen.

When I detect the start of a new thread using “<” character, I then use lcd.clear() to clean the screen. If I do this it seems to throw the rest of the code out of sync and prints the feed onto the second line of the LCD line too soon.

int startstring = 0;
int charcount = 0;
int linetwo = 0;
int clearOnce = 0;
const int initialMarker = 1;

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void newfeed(){
    lcd.clear(); // this line seems to cause syncing problems?

void setup(){
  delay (2000);
  pinMode(13, OUTPUT); 
  pinMode(10, OUTPUT); 
  Serial.println(initialMarker); // print startMarker once

void loop(){
  char incomingByte = 0;
    if (Serial.available() > 0){
      incomingByte =;
      if (incomingByte == '<') {
      if (charcount < 16) {
          charcount++ ;
          else if ((charcount >= 16) && (charcount <=31)){
            if (linetwo == 0) {
              linetwo = 1;
            charcount++ ;
          else if (charcount == 32){
              charcount = 0;
              delay (2000);
              charcount ++;
              linetwo = 0;

    digitalWrite(13, LOW);

I have attached the image of what is happening.

The number of characters it prints on the 1st line before moving onto line 2 reduces with each feed.

Without the lcd.clear() line, the feeds just works as expected and fills up both lines before moving on to the second screen.

If it is required here is the Python code for the feed.

import serial
import feedparser
import time
ser = serial.Serial("\\.\COM3", 9600)

i = 1
y = 0

while i == 1:
  y = int(
  while y == 1:
    sportFeed = feedparser.parse('')

    posts = []

    for z in range(0,len(sportFeed)):
      print  sportFeed['entries'][z].title #, ' | ', sportFeed['entries'][z].updated
      ser.write (str("<"))
      ser.write (str(sportFeed['entries'][z].title))
      ser.write (str('>'))


Thank you

For a normal Arduino Uno/Nano/Leonardo/Micro/Pro Mini board ?

This is the library code :
There is a delay of 2ms after calling the clear command. Perhaps you need a little more ?

delay(2);     // give my display 2 extra ms.

You should reset charcount and linetwo when you clear the LCD.

I have an RSS feed being displayed on my LCD. This works fine as long as I don't use lcd.clear() to clean the screen.

Thank you

Try my LiquidCrystal library. It fixes several bugs in the original one, and adds features as well (including cursor position knowledge and cursor control).

For example, you can use the newline character ("\n") to jump to the next LCD line, and printing a string longer than one line does not disappear into oblivion... it wraps to the next line.

If you want to use this library, go into your existing LiquidCrystal library, rename "LiquidCrystal.cpp" and "LiquidCrystal.h" to something else (for example, append ".old" to each name)., then copy the new ones in place of the old ones.

This should solve all of your problems.

Thank you for all the tips, I corrected it by resetting charcount and linetwo when you clearing the LCD. [oqibidipo]

Krupski - cheers I'll check out your library.