I am working on a project to build a HOTAS (hands on throttle and stick) system for flight sims. I've already got my throttle functioning with all buttons and switches, as well as a potentiometer for throttle position hooked up to a teensy 4.0 inside the throttle handle.
I already have a joystick base but it lacks most of the buttons I need it to have so I am adding a replacement grip that has those buttons.
The part I am currently working on is incorporating the joystick buttons into the teensy. Since there are so many buttons between the two, and I would like them to only take up 1 USB port, I had planned to use shift registers, and use a 3.5mm jack/cable on each component to connect the shift registers to the teensy. I chose a 3.5mm cable as it would be easy to replace if it got worn out as well as it would allow disassembly fairly easily.
Is there a simpler solution than this? I'm trying to keep costs down but I'm afraid I'm overcomplicating it.
Also, is there a way to send analog data through the shift register? like if there were a potentiometer in the joystick, could I send the data to the Teensy?
For shift registers, you would need 3 wires, plus 3.3V & ground, so a total of 5 wires. I've only ever seen 3.5mm plugs & sockets with 4 contacts, so not sure how that could work.
No, you can't connect analog signals to shift registers.
Another option might be i2c I/o expanders. These require only 2 wires plus 3.3V & ground, so that might work. Plus, you can add analog signals to i²c with an ADC chip.
However, i²c won't work over long cables, maybe 1~2m if you are lucky.
You probably need a ground wire to travel along the cable with any data wires, otherwise the data signals might not be readable by the Teensy because otherwise they can pick up stray signals which corrupt the data signal.
Rotary encoders are best connected directly to the Teensy or other MCU, otherwise it's very easy to miss signals, causing the encoder to appear to "slip" if turned too fast.
I would seriously consider i²c if it were my project. It may sound complex, but Arduino libraries are available that will hide the complexities. Consider pcf8574 (8 digital inputs) or pcf8575 (16 digital inputs) and ads1015 (4 analog inputs).
I have an arduino nano laying around that has the correct number if IO pins for the joystick, how reliable would it be to connect that via serial to the teensy? So have all joystick commands processed by the nano, printed to serial, and read by the teensy? That would also allow me to ground the 3.5mm jack since they only need 2 wires to communicate.
Using more than one 'Arduino' in a project is not something I would advise for a beginner. Getting 2 sketches to run without bugs and communicate with each other is more than twice as difficult as one.
But in theory it could work.
One problem is that Nano is a 5V device and Teensy is 3.3V, so bi-directional logic level converters would be needed.