Distance Sensor & LCD

Hi, I hope someone can help me please.

I have bought a cheap sistance sensor which eventually, I hope to use to automate a piece of equipment.
Considering the price, I was very pleasantly surprised to find that it was actually fairly accurate.

I can easily output distances with it to the Serial Monitor.

The problem that I have is that for now, I wish to monitor the output on an LCD.

I am using a I2C LCD backpack to interface the LCD as I will need most of the other pins later on.

Being fairly new to all this, I have reached my limit of understanding on a problem I am having.

When I try to compile the Sketch I get this message:

LCD_Distance_Sensor.ino: In function 'void loop()':
LCD_Distance_Sensor:47: error: invalid conversion from 'int' to 'const char*'
LCD_Distance_Sensor:47: error: initializing argument 1 of 'String::String(const char*)'

Here is my full Sketch:

/*
  
  Distance sensor. Measures in millimetres displaying the reult on a 16 x 2 LCD.
  The LCD is driven via an I2C Backpack. 
 
*/
 
#include <Wire.h>            // Include the I2C Library.
#include <HTI2CLCD.h>        // Include the Library.

#define Trigpin 2            // Set the pin to send trigger pulses.
#define Echopin 3            // Set the pin to receive echo pulses.

HTI2CLCD lcd;                // Create an instance of the HTI2CLCD I2C Backpack.

const int  lcd_address=60;   // I2C Address of LCD backpack.
int bl=0;                    // Backlight power value.

void setup()
{
    pinMode(Echopin, INPUT);                 // Set the mode of the pin.
    pinMode(Trigpin, OUTPUT);                // Set the mode of the pin.
    Serial.begin(9600);                      // Start the serial interface.
    delay(200);                              // A short delay for the LCD to configure itself.  
    Wire.begin();                            // Join I2C bus.
    lcd.setType(lcd_address,2,16);           // Define rows and columns for the LCD.
    lcd.clear(lcd_address);                  // Clear the LCD
    lcd.backLight(lcd_address,100);          // Set the LCD backlight value.
    lcd.print(lcd_address,"Distance");       // Display splash screen text.
    lcd.setCursor(lcd_address,2,1);          // Move the cursor to next row down.
    lcd.print(lcd_address,"Measurement");    // Display splash screen text.
    delay(5000);                             // A delay of 5 seconds to read splash screen.
}

void loop()
{
  digitalWrite(Trigpin, LOW);               // Set the trigger pin to low for 2uS.
  delayMicroseconds(2);                     
  digitalWrite(Trigpin, HIGH);              // Send a 10uS high pulse to trigger the distance ranging.
  delayMicroseconds(10);                    
  digitalWrite(Trigpin, LOW);               // Send the trigger pin low again.
  int distance = pulseIn(Echopin, HIGH);    // Read in times of pulses.
  distance = distance/58;                   // Calculate distance from time of pulses in Centimetres.
  Serial.print(distance);                   // Print the Distance (In cm) to the serial monitor.
  Serial.println(" cm");                    // Print the measurement units to the serial monitor.
  lcd.clear(lcd_address);                   // Clear the LCD screen.
  lcd.print(lcd_address,distance);          // Print the Distance (In cm) th the LCD screen.
  lcd.print(lcd_address," cm");             // Print the measurement units to the LCD screen.
  lcd.setCursor(lcd_address,2,1);           // Move the cursor to the next row down.
  lcd.print(lcd_address,"+/- 1 cm");        // Print the accuracy of the measurement on the LCD screen.
  delay(1000);                              // A 1 second delay.
}

Could anybody please help me with what I need to do to fix this please?

Thank you in advance.

The LCD library's print function isn't as flexible as serial.print - it has two options, a C string or a String object. You'll need to get your distance value in to a C string (preferably) so you can display it on the LCD. Take a look at sprintf.

sprintf will work for integers, but not for floats. you need to turn float values to c-string to use in spritnf using dtostrf.

Thank you for the advice.

Those are two terms that are way over my head at the moment.
I will have to try and do some reading on the subject.
At least you have shown me where to start looking.

Thank you.