#include <16F877A.h>
#device adc = 8
#fuses XT,....
#use delay(clock = 4000000)
#byte trisa=0x85
#byte porta=0x05
float V1,V2;
void Leer_ADC1(void){
setup_port_a( ALL_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );
V1 = read_adc();
delay_ms(20);
setup_adc (adc_off);
}
void Leer_ADC2(void){
setup_port_a( ALL_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 1 );
V2 = read_adc();
delay_ms(20);
setup_adc (adc_off);
}
void main(){
set_tris_a(0x0F);
while (TRUE){
Leer_ADC1();
lcd_gotoxy(1,1);
printf(lcd_putc,"Volt= %5.2f",V1);
Leer_ADC2();
lcd_gotoxy(2,1)
printf(lcd_putc,"Volt= %5.2f",V1);
}
}
#device adc = 8
#fuses XT,....
#use delay(clock = 4000000)
#byte trisa=0x85
#byte porta=0x05
float V1,V2;
void Leer_ADC1(void){
setup_port_a( ALL_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );
V1 = read_adc();
delay_ms(20);
setup_adc (adc_off);
}
void Leer_ADC2(void){
setup_port_a( ALL_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 1 );
V2 = read_adc();
delay_ms(20);
setup_adc (adc_off);
}
void main(){
set_tris_a(0x0F);
while (TRUE){
Leer_ADC1();
lcd_gotoxy(1,1);
printf(lcd_putc,"Volt= %5.2f",V1);
Leer_ADC2();
lcd_gotoxy(2,1)
printf(lcd_putc,"Volt= %5.2f",V1);
}
}
Puede que exista algun error de mala escritura pero si tengo mas tiempo, prometo enviar el codigo y la simulación.
Espero haya sido de ayuda el comentario....Saludos















