#include"16f877a.h"
#device adc=10
#fuses HS,NOWDT,NOLVP,NODEBUG,NOCPD
#use delay(clock=4M)
#int_ext
//--------------START of variable for Pulse delay definition---------------
int valuet;
unsigned long value1;
unsigned int value3,delaya;
//--------------Ends of variable for Pulse delay definition---------------
//--------------START OF variable for temperature reading---------------
byte const digit[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}; //Changed this as there was error in the previous one
char display[2];
int value;
unsigned long volt;
unsigned int value2;
//--------------END OF variable for temperature reading---------------
void isrext()
{
output_c(0xff);
delay_ms(1000);
}
void main()
{
set_tris_a(0xff);
set_tris_b(0x01);
set_tris_c(0x00);
set_tris_d(0x00);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(ALL_ANALOG);
setup_vref(False);
//int x=0;
enable_interrupts(int_ext);
enable_interrupts(global);
ext_int_edge(H_TO_L);
while(1)
{
//------------------Temperature reading and display
set_adc_channel(0);
delay_us(100);
//value=read_adc(); //Not required
read_adc(ADC_START_ONLY);
delay_us(100);
value=read_adc(ADC_READ_ONLY);
//volt=(value*500)/1023; //I changed this part of the code
volt=(value*500)/1023;
value2=volt;
delay_us(1);
output_high(PIN_D1);
display[0]=value2/10;
output_c(digit[display[0]]);
output_low(PIN_D0);
delay_ms(1);
output_high(PIN_D0);
display[1]=value2%10;
output_c(digit[display[1]]);
output_low(PIN_D1);
delay_ms(1);
set_adc_channel(1);
delay_us(20);
read_adc(adc_start_only);
delay_us(20);
valuet=read_adc(adc_read_only);
value1=(valuet*500)/1023;
value3=value1;
delaya=(value3*20)/10;
//delaya=(value3);
output_high(PIN_D3);
delay_ms(delaya);
output_low(PIN_D3);
}
}