SEARCH
TOOLBOX
LANGUAGES
Register    Login    Forum    Search    FAQ

Board index » Electronics Projects » PIC18F USB development




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: LM35 Lcd Display Trouble
 Post Posted: Mon Jun 04, 2012 2:23 am 
Offline

Joined: Mon Apr 19, 2010 4:56 am
Posts: 14
Hi I'm using the pc Case USB LCD Project for a digital termometer with the LM35 sensor this is the code for read temp

unsigned char readTemperature(void)
{
unsigned char temperature;
int result;
float temp;


// Perform ADC on RA0 to read the LM35 voltage output
GODONE = 1; // Start the ADC conversion
while(GODONE); // Wait for the ADC conversion to complete

// Get the ADC result (1023 = +5v (5000 milliVolts)
result = ADRESL;
result += (ADRESH << 8);


// Calculate the current temperature
temp = round( result * 0.488 )+2;


// Return the temperature to the nearest degree C
temperature = (unsigned char)temp;

return (unsigned char)temperature;
}

when i try to display at the lcd using
lcdGoto(0,1);
lcdPuts(readTemperature);
i get this Warning 141.20 illegal conversion of integer to pointer
and the display showme some wrom caracters

could you helpme with this convertion ?


Top 
 Profile  
 
 Post subject: Re: LM35 Lcd Display Trouble
 Post Posted: Mon Jun 04, 2012 6:19 am 
Offline

Joined: Thu Apr 01, 2010 6:23 am
Posts: 898
You have to convert the integer to a string in order to display it.

Include the string functions ( #include <stdio.h> ) and then use something like:

char myString[4];
sprintf(myString, "%d", myInteger);

then print the contents of 'myString' to the LCD. You could even use:

sprintf(myString, "Temp = %d", myInteger);

if you want some extra text (make sure the myString array is long enough though).


Top 
 Profile  
 
 Post subject: Re: LM35 Lcd Display Trouble
 Post Posted: Mon Jun 04, 2012 12:11 pm 
Offline

Joined: Mon Apr 19, 2010 4:56 am
Posts: 14
Thanks to you as always it worked just fine


Top 
 Profile  
 
 Post subject: Re: LM35 Lcd Display Trouble
 Post Posted: Thu Jun 21, 2012 1:29 pm 
Offline

Joined: Mon Apr 19, 2010 4:56 am
Posts: 14
Hi do you have any code to interface the dallas DS1820 I@C termometer chip with Hi-Tech C ?


Top 
 Profile  
 
 Post subject: Re: LM35 Lcd Display Trouble
 Post Posted: Fri Jun 22, 2012 5:02 am 
Offline

Joined: Thu Apr 01, 2010 6:23 am
Posts: 898
I haven't used that chip personally; usually I2C is quite simple though, just find an I2C example for the PIC and alter it according to the data-sheet for the device.


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 5 posts ] 

Board index » Electronics Projects » PIC18F USB development


Who is online

Users browsing this forum: No registered users and 0 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Translated by MaĆ«l Soucaze © 2009 phpBB.fr