I2C LCD Remaining zeros !

I try to display the potentiometer value on LCD, but when I reach a high value and try back to zero 0, the screen still showing zeros instead of clear them .
What I must do ?

Overwrite the old data with spaces before writing new data.

Like so:

#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip

const int LCD_COLS = 16;
const int LCD_ROWS = 2;

const byte potPin = A0;

void setup()
{
   lcd.begin(LCD_COLS, LCD_ROWS);
}

void loop()
{
   static unsigned long timer = 0;
   unsigned long interval = 500;
   if (millis() - timer >= interval)
   {
      timer = millis();
      unsigned int potValue = analogRead(potPin);
      lcd.setCursor(0, 0);  // move the cursor to the starting point
      lcd.print(F("Pot =                ")); // write enough spaces to overwrite old data
      lcd.setCursor(6,0);  // move the cursor to where the new data goes
      lcd.print(potValue); // write new data
   }
}

The hd44780 library is available in the library manager.

The alternative which may be somewhat faster (or may not) is to perform a series of comparisons to the new number, writing a blank for each power of ten which the number does not equal or exceed.

This also causes the number displayed to be “pinned” which is what you generally want so that the units are always in the same place, the tens (a place to the left) and so on. Numbers which dynamically expand to the right are somewhat disconcerting.

(Nothing whatsoever to do with the I2C.)