(SOLVED) Numbers on lcd are not correctly displayed

Hello everyone!
Sorry for my bad english…
I’m trying to control brightness of led light with arduino and I want to display brightness precentage on 16x2 I2C lcd. The problem is, that 3 character number doesn’t display correctly (look at the photos).
If anyone knows how to program arduino so that the number will appear correctly, please let me know.


pwm_ledlight__led_display.ino (775 Bytes)

You need to pad the number with spaces. If you print “100%” to the display and after that print “99%”, the display will show “990%”.

lcd.setCursor(0, 1);
if (brightness < 100) lcd.print(" ");
if (brightness < 10) lcd.print(" ");

Thank you, now numbers are displaying correctly, it works :slight_smile: :slight_smile: