Arduino-based mode switch

FILE0080.jpg?width=750First, I used combinations of switches to select the mode of my APM. But IMHO, there is hardly anything more counter-intuitive and if things hit the fan, you can be sure to switch to the wrong mode out of pure hectic.

Next, I replaced a pot of my transmitter with a 6-position switch and variable resistors. That is already better, but to get to one mode, you likely have to switch through other modes. Also, without any markings, again, not very intuitive and it's impossible to see at one glance which mode you are in.

Finally, I hacked together a small board with 6 pushbuttons, 6 LEDs and an Arduino Pro Mini. The Arduino creates an 8-channel PPM stream of which channel 1 contains the data for the mode. The whole thing connects to the trainer port of my 9x. Additionally, I steal 5V from the display output of my FrSky module but theoretically, the Arduino could also be powered by the 3S transmitter LiPo. The program is pretty easy. Check the buttons and set the respective PPM value. The LEDs are not set by the buttons but by the actual value of PPM1 - just to be safe, in case e.g. the Arduino resets or something.

Here's the schematic:

APM_mode_switch_schem.png?width=750I'll attach design files for the PCB and the source code in the comments then.

E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones


  • I'm no electronics engineer but I use a six position switch from Ebay that replaces one of the rotary switches and I get the six different numbers that the modes are looking for by adjusting small variable pots. Fairly analog and very reliable.  Couldn't the same inputs that are created by the rotary knob and the adjustable pots be used? All you would need is a way to connect six buttons in a way that only one is on at a time, maybe controlled by an Ardino or small micro processor. A simple latching circuit that only allows one button at a time to route the signal through that particular pot that is set to output the correct number for the desired mode like the rotary switch does . No programming or outside connections. I've played with microprocessors a little and it seems doable.

    ebay item (110938433765)

  • IIRC the problems was that when using the T9X as a slave, the TX module needed to be removed or a small resistor soldered in. If you use the trainer port as an input, there's no such problem.

    I use the OpenTX firmware on my 9x. In the mixes menu, I can simply assign PPM1 to any channel (5 for APM:Copter) and it works. I have no idea how it works with the stock firmware. I think, in the stock FW, channel 5 is hardcoded to gear, so you would have change ppm[0] in my code to ppm[4] (for copter) and then set the gear channel to trainer or something like that.

  • MR60
    That is great. Can you explain how the output of the arduino is "connected" (via trainer port) to the channel of the radio that controls mode selection?
    Second question, is there a physical hack required on T9x to use its trainer port ( i have read it does not work out of the box?)
  • A small suggestion: tie the modes you would want in PANIC situations (RTL and stabilise?) to the arduino ports with a interrupt function (2 and 3), so you can programme it to REALLY switches back quickly (use AttachInterrupt() ).

  • mP1

    Put one button away from the others and program it to whichever mode you want for a panic button?

  • Nope, haven't seen that before. It's pretty nice too, but not very universal :).

  • Hi, Stefan, nice work! But did You seen this?

  • That's easy to make, BUT has the same problem as some other solutions. In a hectic situation, it's easy to select wrong. One switch per mode is the most intuitive and that's what you want for safety. That might not be of large consequence if you fly around a Bixler or a small quad. But imagine, you fly a UAV-3000 or a 5kg hex. You don't want THOSE biggies to get out of control!

  • Stefan, I really like your idea.  I was thinking of doing that very thing.  I'm a total noob and this might be a bad idea, I'm curious what everyone would think.  What if instead of the 6 buttons you had one two way momentary toggle switch to select the mode and then one push button "enter" switch.  The Leds could indicate the current mode by remaining solid.  As you operate the toggle, the leds could blink to show what mode is selected.  My thought here would be to mount the enter switch somewhere on the backside of the transmitter for an index finger to operate. I'm not certain where I would put the toggle.     

  • FIxed broken Gerber download.

This reply was deleted.