display float on 16x2 LCD in PIC 16F877 using Hi-tech C compiler

Status
Not open for further replies.

ecaits

Member level 4
Joined
Jan 16, 2014
Messages
76
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
579
Hi friends,

I want to display float value on LCD display in PIC16F877 using Hi-tech C compiler.

Can anybody help me???
 


Hi ecaits,
sprintf() can eat up more memory on PIC16F877. Fixed point arithmetic is good. But if you still want to use float, use the follwoing code to display on LCD.
Code:
#define DECIMAL_PLACES    (100)    // 2 digits after decimal

void displayFloat(float value)              // Assume value = 123.456
{
      unsigned long a = value;              // a = 123
      value = (value - (float)a) * (DECIMAL_PLACES);       // value = 45.6
      unsigned long b = value;              // b = 45

      display(a);
      display('.');
      display(b);
}


Raj Gunaseelan
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…