a/d 12f675 ,i can only use 1 and 2 not 500 to test input on a pot
clean
define adc_bits 10 'adc settings
define adc_clock 3 ' adc setting
define adc_sampleus 50 'adc setting
intcon.6=1 'gloabal interrupt
intcon.7=1 'gloabal interrupt
pie1.6=1 'a/d interrupt
pir1.6=1 'a/d interrupt
adcon0=%10001111 'set an3 on ie gpio.4
ansel=%00011000 ' sets fosc/8 and gpio.4[an3] as adc input
cmcon=7 ' turn off comparator function
trisio=%011000 'set gpio.4 as input and others as output
'define variables
rdg var word 'adc reading from an3
mpin var gpio.2 ' music pin output to speaker
led var gpio.0 'led output
tone var word ' tone value for the sound
'initial setting
led=0
'initial interrupt
on interrupt goto testpot
'program
start:
'reset led
adcin 3,rdg 'get volt reading from an3 and place adc value in rdg
goto start
'isr
disable
testpot:
if rdg =<1 then led=0
if rdg =>2 then led=1 'turn on led if adc value is equal to or larger than 1
tone=1+(rdg)*102 'converts adc value to a tone value of 1 to 120
' necessary to divide by 10 to avoid 65536 word limit
'adc of 0=tone of 1, adc of 1023 = tone of 120
sound mpin,[tone,20] 'provides a tone proportional to input volt duration = 20x12=120 min
resume
enable
end
I changed clock 3 to clock 0
cannot find clock 3 in datasheet it now works thank you