I have to display .0001 in LCD. But when i print a float number, it is printed as 0.0001. For my case, zero in one's not to be display in LCD. I'm using 8x1 LCD display. Is there any possible solution to print like this??
send what value you want to show in LCD by sending ASCII value.
eg) ASCII value for dot(.) in hex is 0x2E and for 0(zero) is 0x30 .
if you want to display .210
multiply with 100, a*100 you will get 21.0 then use some arithmetic
Code:
a=0.210*100 // a=21.0
b=a/10; // b=2
c=a%10; // c=1
lcd_command(0x80);
lcd_data(0x2E) ; // ASCII value for dot
lcd_data(0x30+b); // ASCII value for two
lcd_data(0x30+c); // ASCII value for one
lcd_data(0x30); // ASCII value for zero (0)
by doing this you can display without zero in one's.
I assume that you are using printf function to display float value.
I think you should first check to see if the format string given to the printf fucntion can be given an argument that can strip starting '0'.
If there is no possibility through printf format string then you may instead of using printf function should use sprintf function which will give you string of float number in a buffer or array passed to this function as an argument. You may then strip of the first character from this buffer before actually passing it to lcd display function.