
Originally Posted by
lerameur
right var word 'Create right to store result
left var word
TRISA = %11111111 ' Set PORTA to all input
TRISB = 0
ADCON1 = %11000001 ' Set PORTA analog and RIGHT justify result
ADCON0 = %00000001 ' Configure and turn on A/D Module
Pause 500 ' Wait .5 second
loop: ADCON0.2 = 1 'Start Conversion
notdone: pause 5
if ADCON0.2 = 1 Then notdone 'wait for low on bit-2 of ADCON0, conversion finished
ADCIN 0, right 'Read channel 0
ADCIN 1, left 'Read channel 1
right.highbyte = ADRESH 'move HIGH byte of result to right
right.lowbyte = ADRESL 'move LOW byte of result to right
left.highbyte = ADRESH 'move HIGH byte of result to left
left.lowbyte = ADRESL 'move LOW byte of result to left
Here, inside a forum for PicBasic Pro-Compiler, it is allowed to use some of his commands.
ADCIN 0,left
ADCIN 1,right
...will do the job for you.
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
Bookmarks