I have two projects in which I would like to print a decimal value to a text display (1602 or similar HD44780 display).
One of them is a thermometer that will only display temperatures between 0 and 20 degrees Celsius with one decimal so using "byte" seem optimal. At the moment I will probably not need to do any math with the value so I could use float but I would prefer to instead use byte and add a decimal point when I print it to my LCD display. I have searched for some way to display the third number from the right, add a decimal point and then print the second and first character from the right, but I can not find any information about how to do this. Also, will the Arduino treat the value zero as 0 or 000? If it's just one "0" I could use unsigned int and map the vales to 1000-1200 and then omit the 4th character from the right when printing to the LCD my main problem still remains.
I have searched for some way to display the third number from the right, add a decimal point and then print the second and first character from the right,
I would prefer to instead use byte and add a decimal point when I print it to my LCD display
Let's assume that the value is say 15.9 How will that be stored in a byte ?
I will probably not need to do any math with the value so I could use float but I would prefer to instead use byte and add a decimal point when I print it to my LCD display.
Then, dividing the byte by 10, to get 15, and using % 10 to get 9, and printing "15", ".", and "9" ain't rocket surgery.
The initial value will come from the built in AD-converter and thus be a number between 0 and 1023. At the moment I will most likely be using 4-20mA current loops so actual AD-value may be somewhere similar to 611 to 818 for 0,0°C to 25,0°C
I get dividing my mapped value with 10 to get "15" but the "% 10" is new to me. Is it this arithmetic operator you are referring to?
[edit: yes I am fully aware that I need to use int or similar for the initial value since the AD converter use 10 bits resolution so I can not get away with only using byte