Since we learned ADC example, now we can make a digital thermometer. LM35 gives voltage output linearly calibrated to voltage, such as
temperature=volt/100
So, everything is the same as in ADC example with a few changes
Proteus: instead of POT resistor we put LM35 and connected to RA0
XC8:
code is as below. to calculate volt I multiplied with 500 (temperature conversion coefficient is 100). I added celcius char 223 to the screen before C. That's all.
don't forget to copy myxlcd.h, myxlcd.c and delays.h to local project directory.
#include "mcc_generated_files/mcc.h"
#include "myxlcd.h"
#include "delays.h"
#include <stdio.h>
void main(void)
{
// Initialize the device
SYSTEM_Initialize();
unsigned char v[12];
uint16_t cV = 0;
float volt;
while (1)
{
ADC_StartConversion(channel_AN0);
while(!ADC_IsConversionDone());
cV = ADC_GetConversionResult();
volt=cV*500.0/65536;
sprintf(v, "%.1f", volt);
OpenXLCD(FOUR_BIT & LINES_5X7);
WriteCmdXLCD(DON&CURSOR_OFF&BLINK_OFF);
while(BusyXLCD());
putrsXLCD("Thermometer");
SetDDRamAddr(0x40); // goto second line
while(BusyXLCD());
putrsXLCD("Temp=");putrsXLCD(v);putcXLCD(223);putrsXLCD("C");
__delay_ms(500);
}
download the example
Learning Pic Programing With Xc8 Compiler: Thermometer: Measure Temperature With Lm35 And Show On Lcd >>>>> Download Now
YanıtlaSil>>>>> Download Full
Learning Pic Programing With Xc8 Compiler: Thermometer: Measure Temperature With Lm35 And Show On Lcd >>>>> Download LINK
>>>>> Download Now
Learning Pic Programing With Xc8 Compiler: Thermometer: Measure Temperature With Lm35 And Show On Lcd >>>>> Download Full
>>>>> Download LINK 1e