I need a decimal point in my LCD Display

This should be simple.

I am learning to write 8 bit numbers to my LCD display (its an I2C)

I have learned how to do leading zero blanking and right justify my numbers by using the following:

if ((ValueName) < 100) {
    lcd.print(" ");  // this writes a space to shove the number over one place if the number is 2 digits
    if ((ValueName) < 10) {
      lcd.print(" ");  // this writes another space to shove the number over a total of 2 spaces if less than 2 digits
  lcd.print(ValueName); // now write the number

Now I would like to also show a value such as DEC 33 as 3.3

Can someone help me with a little piece of code to stick a decimal point in between the last two digits?


Are all your numbers 10x the value you want to print?

The easiest way is to print it as a floating point number.

lcd.print(value / 10.0, 1);

The 1 tells it how many decimal places. You must use 10.0 vs 10 to make the number a float instead of an integer if value is an integer.

Alternatively you could print each digit separately using modulo math.
to get the integer and fraction/decimal portion as separate integers.
modulo is the integer remainder after you do an integer divide.

i.e. something like:

intnum = number / 10; 
decnum = number % 10;

intnum is the integer portion of the number divided by 10.
decnum is the portion to the right of the decimal.

If number was 34 then intnum would be 3 and decnum would be 4

Then print them separately:


--- bill


Your first example is perfect…

I am sorry but the display in this picture is bright, but you can see that the MPH number now says 3.3 instead of 33.

// Now MPH
  lcd.setCursor(14, 0); //(column, row)
  lcd.print("   ");
  lcd.setCursor(14, 0); //(column, row)
  if ((Nemo[Speedo]) < 100) {
    lcd.print(" ");
    if ((Nemo[Speedo]) < 10) {
      lcd.print(" ");
  lcd.print((Nemo[Speedo]) / 10.0, 1);

Thanks again for your help.

I work in the movie business and you deserve a main title credit for your assistance on this project.