Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem with displaying float number on LCD. ASAP!!!

Status
Not open for further replies.

hemnath

Advanced Member level 3
Advanced Member level 3
Joined
Jun 24, 2012
Messages
702
Helped
61
Reputation
120
Reaction score
57
Trophy points
1,308
Location
Chennai
Visit site
Activity points
6,589
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??

Thanks in advance :)
 

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.

regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top