How to clear LCD display after data display?

Hi all
I have my whole project working but have one question.

I display multiple data sets but the problem is they arent all the same length, so the new data overlaps my old data.
For example, my first reading is "Temperature" and my second reading is "Sound". The problem lies because Sound is only 5 characters and Temperature is 11 characters so when it displays sound it looks like this
"Soundrature"

Is there a way to clear the display after each reading?

thanks so much.

I have attached that portion of the code so you can see what I am doing.

 //Display Readings
  
  lcd.setCursor(0,0);
  lcd.print("Temperature");
  lcd.setCursor(0,1);
  lcd.print(temp);
  lcd.setCursor(6,1);
  lcd.print("Deg F");
  delay(2000);
  lcd.setCursor(0,0);
  lcd.print("Speed");
  lcd.setCursor(0,1);
  lcd.print(tachvoltage);
  lcd.setCursor(6,1);
  lcd.print("RPM");
  delay(2000);
  lcd.setCursor(0,0);
  lcd.print("Sound");
  lcd.setCursor(0,1);
  lcd.print(soundvoltage);
  lcd.setCursor(6,1);
  lcd.print("dB");
  delay(2000);
  lcd.setCursor(0,0);
  lcd.print("Test");
  lcd.setCursor(0,1);
  lcd.print("Completed");
  delay(2000);
  lcd.setCursor(0,0);
  lcd.print("Press Button");
  lcd.setCursor(0,1);
  lcd.print("To Start Test");

Since you are only showing a snippet of code I have to assume that you are using the LiquidCrystal library. If so, there is a command there to clear the display.

Display can be cleared as whole only. You can overwrite unknown characters by spaces. I think, the most aesthetic way is to overwrite whole row at once with prepared string at exact length.

With most of the displays I've used, Budvar10's suggestion is the best. For the libraries I've used, the clear() function seems slow. Just make a string of blank spaces equal to the display width and print that.

I submit even that is half-arsed, and I'm not even sure that is what Budvar meant. All you need to do is make "sound" the same length as "temperature".

  lcd.print("Temperature");
  lcd.print("Sound      ");
1 Like

Yes, that is what Budvar10 meant also, but as the data will be more complicated it should be more profitable to have a buffer at row length for data preparation before print() call (I suppose some value after "Temperature" text e.g.) to display everything as quick as possible for the best visual result. In addition buffer can be cleared via memset e.g., it avoids to waste flash with spaces.