Pages: [1]   Go Down
Author Topic: How to send a decimal to a 16X2 LCD  (Read 627 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 49
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 64
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Pages: [1]   Go Up
Jump to: