I'm having a problem with reading two analog inputs. The first channel (GPIO.0) works well but the issue is that the next channel reads identically even though the voltage going into the pin is clearly different.

I must be missing something simple, I think that what I am trying to do is quite basic. I've looked at the PicBasic Pro manual, the datasheet and searched the forum. I did see that someone had a similar problem but the solution was not effective for me.

The wiring has been checked over many times, I am confident that the error is in the code.

The intention is to read the two axis and the button of a mini joystick and send the data serially to another uC.

Code:
@ DEVICE PIC12F683, MCLR_OFF
@ DEVICE PIC12F683, INTRC_OSC_NOCLKOUT
@ DEVICE PIC12F683, WDT_OFF
@ DEVICE PIC12F683, BOD_ON
@ DEVICE PIC12F683, PWRT_ON
'-------------------------------------------------------------------------------
DEFINE  OSC 8
Define	ADC_BITS	8	' Set number of bits in result
Define	ADC_CLOCK	3	' Set clock source (3=rc)
Define	ADC_SAMPLEUS	50	' Set sampling time in uS
define  CHAR_PACING 1000

OSCCON = %01110001     ' internal oscillator at 4 MHZ
             
CMCON0 = 0             ' Comparators off
ANSEL  = %00000011	   ' Set 0, 1, analog
WPU    = 0             ' Internal pull-ups = off
GPIO   = %00000000     ' All outputs = 0 on boot
TRISIO = %00011111     ' GPIO.0,1,2,3,4 input, GPIO.5 output

joyY         var   GPIO.0
joyX         var   GPIO.1
joyBtn       var   GPIO.2
Sout         var   GPIO.5

AD      var     byte
X       var     byte
Y       var     byte
Btn     var     byte
B       var     bit

Main: 

adcin joyX, AD

X = AD
AD = 0

pause 1

adcin joyY, AD

Y = AD
AD = 0 

B = joyBtn
if B  then 
Btn = Btn + 1  
else
Btn = 0
endif

if Btn > 100 then Btn = 100   

serout Sout, 2, ["cmd", X, Y, Btn, 128, 128]
goto Main     
     
end
Rich H