How to remove multiple characters on lcd

My circuit consists of a pir sensor, buzzer, lcd, and other sensors but they dont really matter right now, and whenever motion is detected, the lcd shows a "Motion Detected!" message but when there is no motion the lcd is supposed to just stay on the message "Safe". The problem is whenever motion is detected, it shows the appropriate message but after the motion stops it overlaps with the message "Safe". Can someone pls help me.

Full Code:

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);

#define Type DHT11

int sensePin=2;
DHT HT(sensePin,Type);
float humidity;
float tempC;
float tempF; 
int setTime=500;
int delT=500;

int pir=4;
int motion;

int buzzPin=6;

void setup() {
  // put your setup code here, to run once:
  HT.begin();
  lcd.init(); 
  pinMode(pir,INPUT);
  pinMode(buzzPin,OUTPUT);
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  lcd.backlight();
  humidity=HT.readHumidity();
  tempC=HT.readTemperature();
  tempF=HT.readTemperature(true);

  motion=digitalRead(pir);

  if (motion) {
    digitalWrite(buzzPin,HIGH);
    lcd.setCursor(0,1);
    lcd.print("Motion Detected!");

  }
  else {
    digitalWrite(buzzPin,LOW);
    lcd.setCursor(0,1);
    lcd.print("Safe");

  }

  lcd.setCursor(0,0);
  lcd.print("H=");
  lcd.setCursor(2,0);
  lcd.print(humidity);
  lcd.setCursor(8,0);
  lcd.print("C=");
  lcd.setCursor(10,0);
  lcd.print(tempC);

}

Specific Part:

 if (motion) {
    digitalWrite(buzzPin,HIGH);
    lcd.setCursor(0,1);
    lcd.print("Motion Detected!");

  }
  else {
    digitalWrite(buzzPin,LOW);
    lcd.setCursor(0,1);
    lcd.print("Safe");

  }

Try adding 12 spaces to the "Safe" message.
The forum removes a bunch of spaces here:
lcd.print("Safe ");

It worked! Thank you @SurferTim :smiley:

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

#define Type DHT11

const byte sensePin = 2;
DHT HT(sensePin, Type);
float humidity;
float tempC;
//float tempF;
//int setTime = 500;
//int delT = 500;

const byte pirPin = 4;
const byte buzzPin = 6;

void setup() {
  HT.begin();
  lcd.init();
//  pinMode(pirPin, INPUT);
  pinMode(buzzPin, OUTPUT);
  Serial.begin(9600);
  lcd.backlight();
}

void loop() {
  humidity = HT.readHumidity();
  tempC = HT.readTemperature();
//  tempF = HT.readTemperature(true);

  motion = digitalRead(pirPin);

  lcd.clear();
  digitalWrite(buzzPin, motion);

  lcd.print("H=");
  lcd.print(humidity);
  lcd.setCursor(8, 0);
  lcd.print("C=");
  lcd.print(tempC);
  lcd.setCursor(0, 1);

  if (motion)lcd.print("Motion Detected!");
  else lcd.print("Safe");
}

If that is the only thing you have on the display, the clear will work.
Otherwise you need to refresh the entire display.

Edit: Correct. Use clear, put everything back.
I'm an aviation fanatic. I watch commercial aircraft on YouTube shooting IFR approaches.
I can tell when the flight displays use clear instead of overwriting the current data.
The video shows the display going blank (black) half the time. Your eyes don't see it.

for you is recommended not update display at all if no change