Joysticks

Status
Not open for further replies.
I needed extra ANALOG joysticks for my project, and I tried the "extreme joystick" example

I cut and pasted all the files in the ...\cores subdirectory, but when I compiled, I got all sorts of errors - one of which was that 'joystick.x was not described in this scope.." So I went back to my original which looks like this.
/////////////////////////////////////////////////////////////////////////////////
// read analog inputs and set X-Y position
Joystick.X(analogRead(0)+ OffsetX);
Joystick.Y(analogRead(1)+ OffsetY);
Joystick.Z(analogRead(2)+ OffsetZ);
Joystick.sliderRight(analogRead(3)+ OffsetSliderRight);
Joystick.sliderLeft(analogRead(4)+ OffsetSliderLeft);

// a brief delay, so this runs 20 times per second
delay(50);
}
///////////////////////////////////////////////////////////////////////////////

I figured this would get me started, since it has 5 channels and DOES compile and it even seems to work. I can't figure out how to modify the descriptor file, I'll study that some more and try to get another 3 channels.

But now I have another requirement: I need to be able to use TRIM switches to change the center points of the joysticks. Reading the switches cannot be blocking - the switches need to be read while the main program is running. Also, I need to read an EEPROM location for the existing offset, and then increment or decrement that value with successive button presses (one button for increment, another for decrement) and then save that value back to EEPROM. Then I need to add or subtract the value from the A/D reading. I'll need 16 pushbuttons to handle 8 channels.

But I don't yet know what will happen if I decrement below zero. I assume it will roll over (65535 +1 = 0) and I don't want that to happen, and I don't know how to best offset the joystick reading.

Can someone help me a bit with this?
 
Status
Not open for further replies.
Back
Top