Go Down

Topic: How to send a decimal to a 16X2 LCD (Read 714 times) previous topic - next topic


I want to Serial.print() a float number to a 16X2 LCD.  I understand that you cannot Serial.print() a float.  I suppose I can multiply my float by 1000 but my decimal point wont show up on the LCD.  i.e. 1.500 versus 1500

Any suggestions ???????

Does anyone have any code suggestion to Serial.print(float, DEC) which will print the numbers before the decimal point and then somehow Serial.print(".") and then   _somehow_  parse the numbers after the decimal point and print those.

Any help would be welcomed and appreciated.


This probably won't work for huge/tiny values, but what I would do would be similar to:

Cast the float to an int (truncate anything past the decimal) and write that to the LCD.
Print a period '.' to the LCD.
Subtract off the integer part of the float, and multiply by whatever number to get the desired precision.

Hope that helps!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131