Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Lots of buttons for x-plane

  1. #1

    Lots of buttons for x-plane

    Firstly I apologise for my lack of knowledge but I am just starting this journey.

    I fly VFR light aircraft on VATSIM with x-plane in VR.
    I donít need a home cockpit as Iím sitting in the virtual one. But it would be nice to have a physical button to tune the radio. Well thatís where I started, then I began to learn what could be done with a Teensy.
    So now my project is to start with a coaxial rotary encoder for the radio and learn from that, then gradually grow the ďcockpitĒ to around 10 encoders some coaxial,30 buttons and 10 switches.

    Iím happy with writing the code but the hardware bit is all new to me.

    What I could do with is some guidance on is how the numerous outputs (around 70) generated by all these controls get connected to the Teensy, or do I need multiple Teensys, or am I barking up the wrong tree.
    Some very basic guidance please.


  2. #2
    Senior Member
    Join Date
    Feb 2015
    Usually the answer for lots of IO is to use expanders such as MCP23017. It is possible to read encoders over the expander, provided you've got the right software. Something like this: (that's just the first thing that popped up on google, I have no idea if it's any good).

    If you tell us more about what kind of interface X-plane needs, we can help further on that side of things too. Ie, is it just expecting an HID joystick with 70 different buttons?

  3. #3
    Thanks for the response. Unfortunately my lack of knowledge means I can’t really ask the right question and certainly couldn’t implement the solution you found for me. I think I’m going to get a Teensy, a starter kit, and a rotary encoder and do some experimenting and some of the tutorial project to gain knowledge and experience. Maybe the best route is to spread the inputs over two or three Teensys in any case.


  4. #4
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Ayer Massachussetts
    Some general notes.

    Yes, eventually you are going to possibly want 70 buttons, but you are going to want to start small rather than trying to add code to add all 70 buttons at once. And you will find that as you get past certain thresholds of complexity, you need to revisit how to do things, and possibly start over from scratch.

    When you are dealing with that many buttons, you want to do things in units, so that you can test things in isolation. You want to be able to test just say 8 buttons in isolation from all of the other buttons. It can be no fun trying to track down a cracked solder joint when you have some 140+ wires to check.

    The MCP23017 mentioned is a tiny microprocessor that talks on a common bus called I2C. It connects to the Teensy with 4 wires, but it allows you to have up to 16 different digital inputs or outputs, On the I2C bus, you can have multiple of these devices. Each device has an address. This means you can have one MCP23017 controlling 16 buttons, or 8 buttons and 8 leds for the buttons. You can test each MCP23017 in isolation, and then reattach things to try the large programs. You need something like a MCP23017 (or use multiple Teensys, other methods, because a single Teensy 3.6/3.5 doesn't have that many pins to control 70 buttons directly.

  5. #5
    Junior Member
    Join Date
    Sep 2019
    Essex, UK

    Expanding the GPIO count

    Hi, I have experience of using multiple MCP23S107's - the SPI variant of the same chip you mention, and they work great - I currently have 7 of them hooked up to a Pi and via an ISR can reliably read 112 gpio's. I am in the process of porting this python code to C on a teansy 4 and can highly recommend the library written by Sumotoy here.
    I have at present 1 expander chip working via an ISR and am working on abstracting that code to allow multiple chips to be read via individual interrupts however I've not had time to progress this much and my coding skills are somewhat basic which hampers my progress! What I want to do (as I have done in python) is create a class for the ISR so that multiple instances can be simply launched for each GPIO chip, - not sure if this is the best solution to my problem, as said I'm a novice when it comes to C programming.
    BTW I'm using these chips to read 30+ rotary quadrature encoders to control some LED banks in my house and even with python on the Pi I see end-end latency <3ms and on a single chip on the teansy <3us

  6. #6
    More great info, I’ve now found fritzing too. Hopefully this button project is not going to become more interesting than actually flying the simulator. Read some stuff about the, is this the sort of thing I would use to get more inputs on my system.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts