VEX Controller Giving Weird Values

Hi Apetrunk,
I’m copying here to unofficial answers, since typically the large community of experienced users has more bandwidth to help with specific problems than the EasyC people, especially for general programming questions.

Originally posted by Apetrunk:

If you click on the API.h you will find these lines:

int GetJoystickAnalog(unsigned char ucJoystick, unsigned char ucChannel);
unsigned char GetJoystickDigital(unsigned char ucJoystick, unsigned char ucChannel, unsigned char ucButton); 

This means that GetJoystickAnalog is type int (not unsigned int) so you should fetch to that. You can/should check API.h for all these variable types of inputs and outputs.

It sounds like your debug application is similar to the Projects/Examples/GraphicalDisplayJoystickTest

Try copying that (more exactly).

ch1 must be an int for the code to work properly.

Original

unsigned char ch1;
while(1)
{
ch1=GetJoystickAnalog(1,1);
PrintTextToGD ( 14 , 39 , 0 , "%d\n" , ch1 ) ;
}I have more, but the rest of it is commented out.

Edited

unsigned int ch1;
while(1)
{
ch1=GetJoystickAnalog(1,1);
PrintTextToGD ( 14 , 39 , 0 , "%d\n" , ch1 ) ;
}I have more, but the rest of it is commented out.

V4 you shouldn’t be using Unsigned the joystick returns a signed number
127 to -127. So use a char, or int to store it’s number.