| Author |
Message |
|
optivista
|
Post subject: LM35 Lcd Display Trouble Posted: Mon Jun 04, 2012 2:23 am |
|
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 ?
|
|
 |
|
 |
|
Simon Inns
|
Post subject: Re: LM35 Lcd Display Trouble Posted: Mon Jun 04, 2012 6:19 am |
|
Joined: Thu Apr 01, 2010 6:23 am Posts: 889
|
|
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).
|
|
 |
|
 |
|
optivista
|
Post subject: Re: LM35 Lcd Display Trouble Posted: Mon Jun 04, 2012 12:11 pm |
|
Joined: Mon Apr 19, 2010 4:56 am Posts: 14
|
|
Thanks to you as always it worked just fine
|
|
 |
|
 |
|
optivista
|
Post subject: Re: LM35 Lcd Display Trouble Posted: Thu Jun 21, 2012 1:29 pm |
|
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 ?
|
|
 |
|
 |
|
Simon Inns
|
Post subject: Re: LM35 Lcd Display Trouble Posted: Fri Jun 22, 2012 5:02 am |
|
Joined: Thu Apr 01, 2010 6:23 am Posts: 889
|
|
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.
|
|
 |
|
 |
|