Note: This is a cross-posting from a topic I put on the Processing forum. Thought it might be useful for Arduino-heads to see.
I have been working on a custom joystick - a Navy joystick from the Battleship New Jersey museum ship. It turns out it appears to have what I’m calling ‘logarithmic’ pots (@quark thought they might be exponential). There is a thread: “Need to ‘linearize’ a logarithmic pot” where @jeremydouglass gave lots of great input on this.
Here is the outcome of this effort - may be helpful for anyone building a custom joystick.
This stick is communicating with a Processing script which is emulating a radar screen. The joystick moves a cursor around the display. Previously I had a Logitech 3D Extreme stick with worked great with GameConrolPlus. However the stick (as most gaming sticks do) always self-centered - which was not the way the Navy stick worked. Since the Navy stick was such a mechanical marvel I decided to use one of those instead.
I started with an Arduino Micro and used the Arduino Joystick library to make it an HID device. Sad to say GameControlPlus would not recognize it. So I went for a serial interface using a CP-2104 USB-Serial board to make a port that Processing could access. At 57600 baud there doesn’t seem to be any serious delays getting the data over. The Micro is a 32U4 which has a serial1 port on pins 0 & 1.
Lesson #1: If you want to have the stick display values from -1 to 1 like a standard joystick, you map like this:
This will put the centered joystick at 0, and extremes at -1,1.
Lesson #2: If your pot is NOT linear (probably log but could be exp) and you are reading it with an Arduino, there is a great scaling solution here:
Fscale Library. Most of it is pretty easy to sus out, but the ‘curve’ argument escaped me - lots of trial-and-error on this var.
For Extra Credit: The Ardunio ADC is only good for 10-bit resolution. In hopes of getting something finer I discovered a great library that can increase the ADC resolution! I’m using 14 bits and the throughput seems to be just fine. The library (By Gabriel Staples) can be found here: [Analog Oversample](http:// http://bit.ly/2HL6Ckb) I’m not sure if this is really necessary but trying it out now.
I’m also including pix of this cool joystick - I think I read it cost the Navy about $8k!