Wierd LCD Print Problem.

The attached I2C LCD sketch print has me baffled!

I want a consistent one line LCD print that looks like e.g. this "SWR=2.5:1". I formed this with three separate print statements:

lcd.print("SWR=");//1st display part.
lcd.print(dec,1);//2nd display part (the 1 keeps display to signal fraction digit).
lcd.print(":1");//3rd display.

I did three separate println's because I was unable to figure out how to easily concatenate the two strings and one variable ..... if this is even possible.

This works OK when the variable (dec) preceding the colon is 10.0 or greater. BUT when the variable is less than 10, I get e.g. this: "SWR=9.9:11. Now where does the extra 1 come from?

Stumped ???

bin2dec.ino (1.03 KB)

The "extra" 1 comes from previously printed, longer lines. Put the delay(2000) back in so that you can see it happen.

You need to either clear the display or erase the line completely before printing.

Or do this:

lcd.print(":1  ");//3rd display.

Thanks jremington :slight_smile:

Your lcd.print(":1 "); suggestion corrected the problem! Thanks also for describing the reason for the problem in the 1st place.

I'm pretty much a noob at this C++ stuff.