#include "16f877a.h"
#device adc=10
#fuses HS,NOWDT,NOLVP,NOCPD
#use delay(clock=4M)
float volt, oldval,volt1 ;
void main()
{
set_tris_a(0xff);
set_tris_b(0x00);
set_tris_c(0x00);
set_tris_d(0x00);
setup_comparator(NC_NC_NC_NC);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(AN0);
set_adc_channel(0);
setup_vref(FALSE);
output_d(0x00);
while(1)
{
delay_us(20);
read_adc(adc_start_only);
delay_us(100);
volt = read_adc(adc_read_only);
volt = volt * 30.0/ 1023.0;
if(volt>1)
{
delay_ms(3);
output_high(PIN_D0);
delay_ms(10000);
}
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?