Cutting off the last digit.

Hey folks, i'm new to this Forum and have a Question.
In my Sketch i let Display an Integer (range 0 - 19) on a LCD Display.
Now my Problem is, that if I go below 10 the display will for example show the 9 as a 90 which is not that what I wanted. How can I cut the last digit so that the Display will show the 9 as a 9?

That is the Code for the Display and the String.

if (address == 0x2214)
  {
    unsigned int radChanValue = (value & 0x001f) >> 0;
    lcd.setCursor(0,0);
    lcd.print("CHN:");
    lcd.setCursor(4,0);
    lcd.print(radChanValue);
  }

If you have extra character space on the LCD then just print a space (lcd.print(" "):wink: after radChanValue and this will overwrite the zero from your example.
If you don't have the character space then only print the space if radChanValue is below 10 (a single character)

It's a long time ago since I used C++.
But i think there was a Round Function but I have no clue how it was used.
Sadly I could not overwrite the zero. :frowning:

EDIT: I was just to stupid to overwrite it. Now it works. Thanks for the support :slight_smile:

Your code leaves the zero character on the screen after the value 10 is printed. You can solve this several ways. Perhaps the easiest is:

if (address == 0x2214)
  {
    unsigned int radChanValue = (value & 0x001f) >> 0;
    lcd.setCursor(0,0);
    lcd.print("CHN:");
    lcd.setCursor(4,0);
    lcd.print("  ");               // Two blank spaces
    lcd.setCursor(4,0);
    lcd.print(radChanValue);
  }

I think a slightly better solution is:

if (address == 0x2214)
  {
    unsigned int radChanValue = (value & 0x001f) >> 0;
    lcd.setCursor(0,0);
    lcd.print("CHN:");
    lcd.setCursor(4,0);
    lcd.print(radChanValue);
    if (radChanValue < 10)
       lcd.print(" ");
  }