#include<C:\Program Files\Microchip\Third Party\PICC\Devices\16f88.h>
#fuses INTRC_IO, NOWDT, PUT, NOMCLR, NOBROWNOUT
#use delay(clock=4000000)
unsigned char value;
void setup_16F88();
void infiniteloop(void) ;
void main()
{ setup_16F88();
infiniteloop() ;
}
void setup_16F88(void)
{ set_tris_a(0xbf); //Define all possible input Bits as Input
set_tris_b(0x00); //Define as all output bits
/*Setting Analog comparator mode in which there are two analog comparators Comp1 and Comp2. Our analog inputs are applied on Channel AN1 and AN2, the output is available on C2OUT, which is either a ‘0’ or ‘1’. The input to other comparator COMP1 are AN0 and AN3 and the output is available on C1OUT bit. AN0 and AN3 input ports are grounded in this configuration. */
setup_adc_ports(sAN0|sAN1 |sAN2 |sAN3);
delay_us(20); // for stabilization
setup_comparator(A0_A3_A1_A2); //A0 and A3 input to Comp1 with output at C1OUT
//A1 and A2 input to Comp2 with output at C2OUT
}
void infiniteloop(void)
{ while(1)
{ output_b(C2OUT); // the C2OUT is a single bit, put on port_B0.
}
}