program PIC12F675_AD_001
dim temp as word
main:
ANSEL = %00000100 ' Configure AN2 pin as analog
GPIO = %00000000 ' Initialize GPIO port
CMCON = %00000111 ' Comparator Off
' IOC = %00001000 ' Interrupt-on-change enabled on GP3(=1)
'OPTION_REG = %00000000
TRISIO = %00001100 ' GP0,1,4,5 is OUT
' GP2 in IN
' GP3 is always IN
' INTCON = %00001000 ' Enables the GPIO port change interrupt
ADCON0.VCFG = 0 ' Voltage Reference bit (0 = VDD)
ADCON0.ADFM = 1 ' A/D Result Formed bit (1 = Right justified)
LEDLoop:
temp = Adc_Read(2)
GPIO.0 = 1
Vdelay_ms(temp)
GPIO.0 = 0
Vdelay_ms(temp)
goto LEDLoop
end.