Code or physical error?

So my code is pretty simple. I have it set to map a voltage to a percentage. The code works, however, when i go from 0% to 100% and back it shows more than 1 % symbol…it starts out just fine, till i get to more than 1 digit place. Im lost…

Code.

Sorry forgot that attachment…here it is…

sketch_may11a.ino (2.41 KB)

Or you could have posted it, in code tags.

  display.print (percent,0);

What is the point of declaring percent to be a float, then printing it as though it was an int?

What happens when you print 9 over the top of 10?

There's a big clue in that last question.

(deleted)

spycatcher2k:
Try :

display.print (percent,0);

display.print ("  "); // 2 Spaces

It sort of worked...but not completely... when i added the line the % symbol shifted to the right 2 spaces and instead of having a bunch of em, i only had 2 symbols...

so then i thought, what if i add the space to the display of %

display.print (" % "); // space before and after the symbol.. It worked..

thanks for the help and patience...

A slightly different method, if you want the % to always print in the same place:

  Percent();
  display.setTextSize(3);
  display.setTextColor(WHITE,BLACK);
  display.setCursor(35,40);
  if (percent < 100) display.print(" "); //print leading space if no 100's digit
  if (percent < 10) display.print(" "); //print leading space if no 10's digit
  display.print (percent,0);
  display.println("%");

david_2018:
A slightly different method, if you want the % to always print in the same place:

  Percent();

display.setTextSize(3);
  display.setTextColor(WHITE,BLACK);
  display.setCursor(35,40);
  if (percent < 100) display.print(" “); //print leading space if no 100’s digit
  if (percent < 10) display.print(” “); //print leading space if no 10’s digit
  display.print (percent,0);
  display.println(”%");




Oh ok.. thats not a bad idea too.. ill have to try it too.. thanks