Arduino mode switch for Arduplane / arducopter



HK 6ch v2 mixer settings


cable for TX configuration from PC this
utility DigitalRadio
configure chanel to range1000-2000 ms.



psb and skin




Arduino code

s1 - s5 & LEDS connected to analog pins 1-5
its numbers from 14 to 18

#define AnalogOut 10 // PWM out
int SelBtn = 14; // default
int BtnLevels[19];

void setup()

//5 of 6 modes

BtnLevels[14] = 0; // 1 button
BtnLevels[15] = 84;
BtnLevels[16] = 127;
BtnLevels[17] = 169;
BtnLevels[18] = 255; // 5 button
//force pwm
TCCR1B = 0x01;
pinMode(SelBtn, OUTPUT);
analogWrite (AnalogOut, BtnLevels[SelBtn]);
void loop()

void ScanBtns()
for  (int i=14; i <= 18; i++)

void ScanBtn(int ScanPin)
if (SelBtn != ScanPin) 
pinMode(ScanPin, INPUT);
if (digitalRead(ScanPin)==0)
      SelBtn = ScanPin;
      while (digitalRead(ScanPin)==0); // hold scaning until relise button
      pinMode(ScanPin, OUTPUT);

void unsetOther(int excludePin)
for  (int i=14; i <= 18; i++)
    if (i != excludePin)
        pinMode(i, INPUT);
analogWrite (AnalogOut, BtnLevels[excludePin]);

TX  Hobby King 2.4Ghz 6Ch  :



PSB Layout & chematic download
E-mail me when people leave their comments –

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

Join diydrones


  • I'm doing different version of similar module and I would like to known

    Why did he use 3x 3k resistor and 3x 3.3 uF cap on analog pwm out ?

  • I sent you an email.. thanks Alexey

  • its no commercial forum i cant show price here

    please all details by email

  •                 Comment by Charles lakins 43 seconds ago           Delete Comment

    your board would work fine for me the way it is ,a sixth button is not needed for my use anyway

    How can i purchase one from you?

  • yes i do.

    my mail

  • Hi Charles

    i can produce one this

    board for you. its have 5 chanels but but additional led and button may be connected externaly.
    board with lenses as at video was produced by my friend
    full gallery of self-making clones of this project you can see here
    Переключатель режимов ардупилота - Дневники - RC Форум
    Переключатель режимов ардупилота alexeykozin
  • Looks awesome Alexey!

    I'll buy one if you ever produce them for sale :)

  • it would be great to have it all on one circut board to use under my groundstation panel then i could interface it via the trainer cable only when the groundstations hooked up

    i run my ardupilot off my gear switch

    so when its not on trainer (controlled by flightstick)

    i can use the same setting as on position for RTH and manual when off

  • is it possible the arduino can run your code and this one (below) at the same time and do two functions

    Code: Joystick   build thread:

    or would it be too many pins used for the features (analog or digital)
This reply was deleted.