display xx.xx

General discussion on mikroC.
Post Reply
Author
Message
thinkpositivex23
Posts: 8
Joined: 01 Mar 2010 09:24

display xx.xx

#1 Post by thinkpositivex23 » 30 Jan 2011 17:34

hello...

i write a codding to make a volt meter...
i use LM35
and want to disply at LCD

Code: Select all

char *text = "testing...";
float blinkc ;
char txt[18];
float temp;
void main() 
{
  ADCON1 = 0x80;         //
  TRISA = 0b111111;      //
  Lcd_Init(&PORTC);         // Initialize LCD connected to PORTB
  
  Lcd_Cmd(Lcd_CLEAR);       // Clear display
  Lcd_Cmd(Lcd_CURSOR_OFF);  // Turn cursor off
  Lcd_Out(1, 1, text);      // Print text to LCD, 2nd row, 1st column
 while(1)
 { 
  temp = ADC_Read(0);
  blinkc = (5*temp)/10.24;
  FloatToStr(blinkc, txt);  

  Lcd_Out(2,1,txt);
  Lcd_Out(2,10,"degree");   
 } 
}//~!
while ADC read temp such as 30.something degree
lcd display by follow my calc and floatto str is
30.00000

how to show at LCD just 30.00 ?
please help me...
thanks

KaranSoin
Posts: 130
Joined: 07 May 2010 22:27
Location: Melbourne, Australia

Re: display xx.xx

#2 Post by KaranSoin » 31 Jan 2011 07:12

Use sprintf(). But the function is not available to micro-controllers with low program memory (life a lot of older 16F series).

Regards

thinkpositivex23
Posts: 8
Joined: 01 Mar 2010 09:24

Re: display xx.xx

#3 Post by thinkpositivex23 » 31 Jan 2011 10:10

owh...like that....thanks..

fyi i use PIC16F876A...

i already look about sprintf()

but i not much understand about how to write this code...
can you show to me....
thanks...

Acetronics
Posts: 715
Joined: 27 Dec 2006 14:33
Location: Le Tréport , FRANCE

Re: display xx.xx

#4 Post by Acetronics » 31 Jan 2011 10:35

Hi,

Think positive and help yourself :wink: :

Open the Onewire example and see how the "temperature number" is displayed ...

That simple.

Alain

KaranSoin
Posts: 130
Joined: 07 May 2010 22:27
Location: Melbourne, Australia

Re: display xx.xx

#5 Post by KaranSoin » 31 Jan 2011 17:54

cheers to think positive and helpurself :wink: , however i will give u a head start

Code: Select all

sprintf(txt,"%0.02f",blinkc);
Now u may have to help urself in understanding what that 0.02f jazz is all about.


cheers

thinkpositivex23
Posts: 8
Joined: 01 Mar 2010 09:24

Re: display xx.xx

#6 Post by thinkpositivex23 » 01 Feb 2011 10:10

thanks :D for your advise...

i already done my code...and its work fine....

thanks & regards

Post Reply

Return to “mikroC General”