PIC16F877A and LM35 Based Temperature Monito2
PIC16F877A and LM35 Based Temperature Monito2
PIC16F877A and LM35 Based Temperature Monito2
Monitor
This is a simple project showing you how to read LM35 analog temperature sensor using a PIC
microcontroller and to switch a certain load at a certain temperature.
Software in use:
CCS PIC-C Compiler
Labcenter Proteus VSM
www.facebook.com/ELECTRONICS.LOVERZ
The Schematic Design
The C-Code:
/*
PIC16F877A and LM35 Based Temperature Monitor
Badr Ghatasheh
[email protected]
*/
#include <16f877a.h>
#device adc=10 // Set ADC resolution to 10Bit
#fuses XT,NOLVP,NOWDT,NOPROTECT
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,ERRORS)
#include "lcd_flex.c"
void main()
{
/* ADC Initialization */
setup_adc(ADC_CLOCK_INTERNAL); // initialize ADC with a sampling rate of
Crystal/4 MHz
setup_adc_ports(RA0_ANALOG); // set PIN_A0 as analog input channel
set_adc_channel(0); // point ADC to channel 0 for ADC reading
delay_ms(1); // ADC module is slow, needs some time to
adjust.
/* Peripherals Configurations */
lcd_init(); // Turn LCD ON, along with other
initialization commands
output_low(LOAD); // the load is initially OFF
lcd_gotoxy(1,1); // point LCD cursor to col1 row1
lcd_putc("Temperature is:"); // print on LCD