# Custom Joystick Lessons Learned

**URL:** https://discourse.processing.org/t/custom-joystick-lessons-learned/9722
**Category:** Gallery
**Created:** [March 28, 2019, 2:32pm UTC](https://discourse.processing.org/t/custom-joystick-lessons-learned/9722 "2019-03-28T14:32:59Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![alan856](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@alan856](https://discourse.processing.org/u/alan856)
#### Post date: [March 28, 2019, 2:32pm UTC](https://discourse.processing.org/t/custom-joystick-lessons-learned/9722/1 "2019-03-28T14:32:59Z")

</div>

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:  
map(Axis,min\_analogRead,max\_analogRead/2,-1,1);  
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: [http://bit.ly/2HFZPrS](http://bit.ly/2HFZPrS) called ‘Fscale’. 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: [http://bit.ly/2HL6Ckb](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!

=Alan R.

* * *

![joystick-s](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/45356442217e666a9c17a653ed41d7b683eb803c.jpeg)
