Syntax problems with joystick and servo

What I want to do is use the integer values from my joystick to pan a servo side to side. The problem I’m having is converting the integer value to uint for the servo pulse. Has anyone else ran across this problem and found a soloution?

Thanks, Casey.

Welcome to the forum!

http://www.tinyclr.com/forum/1/1904/

woops.

Does your joystick use 0 as a centre value? If it does, you want to do:

uint val = joystickPos + 2147483647;

This will make 2147483647 your centre position. allowing you to keep the full range of the integer value.

I’m not sure if the joystick is 0 -> 2147483647 as a range. You might want to view the joystick object in the debugger first to see what the range of the values is. On windows using directX you only get -32768 to 32767 as a possible range.

How about this:

uint val = (uint)(joystickPos + int.MaxValue);