(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.

Pictures:
https://drive.google.com/drive/folders/1SECY20wdjY2ZOWgVgZ_H0E3zQ0iVb1aI?usp=sharing

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(" ");
lcd.print(brightness);
lcd.print("%");

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