Professional Documents
Culture Documents
Faculty of Engineering
Project Exam
introduction:
This tutorial is to help us on how to design, build, and code with Micro C, a
temperature montoring system using the PIC16F877A Microcontroller. This
circuit is built to read the input temperature with the help of the LM35
temperature sensor. This temperature is converted into an analog value
using the microcontroller , which performs a certain task depending the
temperature value.
When the tempearture is beyond the threshold temperature, the fan will
automatically turn ON and the heater will turn OFF, and when the
temperature is below the threshold value, the fan will turn OFF and the
heater will turn ON. The temperature value including the sstatus of the fan
and heater are all being displayed with the help of the Liquid Crystal
Display.
Black diagram :
Project components:
1) rrllortnocorci4aC4CF6aCPP a.
2) An LM35 Tempearture sensor.
3) 2 relays .
4) a fan .
5) a heater .
6) tow capacitors and a crystal oscillator: used to produce an input clock
frequency into the microcontroller.
7) 10K resistor and a pushbutton to reset Microcontroller when need.
8) a 5V dc input voltage source.
9) (2) 10K potentiometers: One to vary the LCD contrast and the other
one to vary the measured voltage.
Code Program :
/* Written By Eng. Ali bahameem
*/
//
//
float temperature;
float Displaytemp;
char temp[4];
//
void main(){
//
//
//
Lcd_Out(1,1,"temperature"); //3
Lcd_Out(2,1,"sensor"); //4
delay_ms(3500);
//
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
//
while(1){
temperature=ADC_Read(RA0);
floattostr(Displaytemp,temp);
Lcd_Out(1,2,"temperature=");
Displaytemp=(temperature*50*10)/1023;
Lcd_Out(2,12,Ltrim(temp));
//
Lcd_Out(2,16,"C");
delay_ms(500);
if(Displaytemp<22){
PORTC.F0=1; //HEATER ON
Lcd_Out(3,-3,"HEATER ON");
Lcd_Out(3,-3,"FAN OFF");
Lcd_Out(3,-3,"HEATER OFF");
Lcd_Out(3,-3,"FAN OFF");
if(Displaytemp>25){
Lcd_Out(3,-3,"HEATER OFF");
Lcd_Out(3,-3,"FAN ON");