Yo guys! I need some help once again. In my sketch i have Delay1 and Delay2, wich is changable variable with input tasters. So, i want print that values on LCD. The whole thing works fine, until my delay is 1500ms or 2500ms. So, i tried to use Float insted of Integer, like this..
lcd.print(delay1/1000); // Delay1 is for example 1500
LCD displays 1.50, or 2.00 if delay is 2000. I want to display 1.5 or just 2. Can i somehow get rid of that?
It's works, but not good enough. Increasment of delay is 500ms on every push.. So if i write "lcd.print(delay1/1000, 1);" works fine with 1500, but if delay is 2000 it's 2.0.. I need solution for both cases.
Thug-Life:
It's works, but not good enough. Increasment of delay is 500ms on every push.. So if i write "lcd.print(delay1/1000, 1);" works fine with 1500, but if delay is 2000 it's 2.0.. I need solution for both cases.
int tenths = (delay1 / 100) + 0.5;
if ((tenths % 10) == 0) . // if rightmost digit is 0
lcd.print(tenths / 10); // Print as integer
else
lcd.print(tenths/10.0, 1); // Print with one decimal place