ANALOG TO DIGITAL (ADC) COMPARE 2 INPUT

#include<p18f4580.h>
#include<delays.h>
#pragma config OSC=HS
#pragma config LVP=OFF
unsigned int SLOP;
void adc(unsigned int);
void main(void)
      {
      unsigned int AN0,AN1;
      ADCON0=0X05;
      ADCON1=0;
      ADCON2=0XEE;
      TRISB=0;
      while(1)
           {
           adc(1);
           AN0=SLOP;
           adc(5);
           AN1=SLOP;
           if(AN0>AN1)
           PORTB=0XF0;
           else if(AN0<AN1)
           PORTB=0X0F;
           else if(AN0=AN1)
               {
               PORTB=0XFF;
               Delay10KTCYx(255);
               PORTB=0;
               Delay10KTCYx(255);
               }
           }

      }
void adc(unsigned int D)
{
    Delay10KTCYx(1);
    ADCON0=D;
    Delay10KTCYx(1);
    ADCON0bits.GO=1;
    while(ADCON0bits.DONE==1);
    SLOP=ADRESH;
    SLOP<<=8;
    SLOP=SLOP|ADRESL;
}


//INPUT AN0 AND AN1 TO PIN2... USE TWO VARIABLE RESISTOR PIN1 TO 5V AND PIN3 TO GND
//OUTPUT PORTB 8LED
KEMBALI KEATAS