LIST	P=12F675,	R=dec
#include "P12F675.INC"

	__CONFIG	_PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _BODEN_OFF  & _CP_OFF & _MCLRE_OFF

    #define LED GP2
    	
    cblock    0x20
    ADC_value    
    endc

    org        0
    movlw	0x01
    movwf	ADCON0
    banksel ANSEL
    movlw     0x11           
    movwf     ANSEL        
    movlw     0x07         
    movwf     CMCON
    bcf        TRISIO,LED    
    banksel GPIO
loop:
    call    read_ADC    
    movfw    ADC_value   
    sublw    0x40           
    btfss    STATUS,C    ?
    goto    LED_on        
    bsf        GPIO,LED    
    goto    loop
LED_on:
    bcf        GPIO,LED
    goto    loop


read_ADC:
   bsf ADCON0,1           
WaitADC:
    btfsc PIR1,ADIF
    goto WaitADC           
    movf ADRESH, W        
    movwf ADC_value
    return

    end