#include <12F675.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC //Internal RC Osc
#FUSES PUT //Power Up Timer
#FUSES PROTECT //Code protected from reads
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOCPD //No EE protection
#device adc=8//La resolución del módulo A/D es de 8 bits.
#use delay(int=4000000)
float Voltaje=0;
int8 X=0;
void main()
{
setup_adc_ports(sAN3|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(3);
delay_ms(5);
setup_comparator(NC_NC);
set_tris_a(0x10);
while(1){
set_adc_channel(3);
delay_ms(5);
X=read_adc();
delay_ms(30);
Voltaje=(X/255.0)*13.0;
if(0<=Voltaje<=9.0)
{
output_high(PIN_A0);
output_Low(PIN_A1);
output_Low(PIN_A2);
}
if(9.0<Voltaje<=11.0)
{
output_high(PIN_A1);
output_Low(PIN_A0);
output_Low(PIN_A2);
}
if(Voltaje>11.0)
{
output_high(PIN_A2);
output_Low(PIN_A0);
output_Low(PIN_A1);
}
}
}