#include <16F877A.H>
#device ADC=10
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20000000)
#include "C:\Users\deli\Documents\Google Talk Received Files\teng\brum\Flexlcd2.c"
//==========================
#define LED1 PIN_D7
#define LED2 PIN_D6
#define LED3 PIN_D5
#define LED4 PIN_D4
void main(void)
{
int16 temp_adc,counter1;
int temp, inout_counter=0,PIR1,PIR2,in,out;
setup_adc(ADC_CLOCK_DIV_8);
setup_adc_ports(PIN_A1);
set_adc_channel(1); //read analog input from channel 1
lcd_init();
lcd_putc("\fTemperature:\n");
while(1)
{
PIR1=0;
PIR2=0;
in=0;
out=0;
temp_adc = read_adc();
temp = 5.00*temp_adc*100.00/1023.00;
lcd_gotoxy(1,2);
printf(lcd_putc,"%d",temp);
{//?
PIR1 = input(PIN_B6);
PIR2 = input(PIN_B7);
if(PIR1==1)
{
for(counter1=2000;counter1>0;counter1--)
{
PIR2 = input(PIN_B7);
delay_ms(1);
if(PIR2==1)
in=1;
}
if(in==1)
inout_counter++;
}
else if(PIR2==1)
{
for(counter1=2000;counter1>0;counter1--)
{
PIR1 = input(PIN_B6);
delay_ms(1);
if(PIR1==1)
out=1;
}
if(out==1)
inout_counter--;
}
if(inout_counter>0)
{
if((temp<20))
{
//delay_ms (500);
output_high(LED1);
}
else
{
output_low(LED1);
}
if ((temp>= 20) && (temp_adc <30))
{
output_high(LED2);
}
else
{
output_low(LED2);
}
if ((temp_adc >= 30))
{
output_high(LED3);
}
else
{
output_low(LED3);
}
}
else
output_high(PIN_D4);
}
}
}