You are on page 1of 1

#include <16F877A.

h>
#device adc=10
#FUSES XT,NOWDT
#FUSES
#use delay(clock=4000000)
#include <LCD.C>
void main(){
int16 q;
float p;
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
lcd_init();
for (;;) {
set_adc_channel(0);
delay_us(20);
q = read_adc();
p = 5.0 * q / 1024.0;

//Canal 0 analgico
//Fuente de reloj RC

//Habilitacin canal0
//Lectura canal0
//Conversin a tensin

printf(lcd_putc, "\fADC = %4ld", q);


printf(lcd_putc, "\nVoltage = %01.2fV", p);
if(p<3.50)
OUTPUT_HIGH (PIN_C0);
if(p>3.51)
OUTPUT_LOW (PIN_C0);
delay_ms(100);
}
}

You might also like