Arduino mode switch for Arduplane / arducopter

 


P5162318.jpg?height=300&width=400


HK 6ch v2 mixer settings

config_radio.jpg?height=294&width=400

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

modes_tune.jpg

 

psb and skin

modesw.jpg

schematic


modesw-sh.gif


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()
{
 
Serial.begin(9600);

//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;
delay(100); 
 
pinMode(SelBtn, OUTPUT);
digitalWrite(SelBtn,0);
analogWrite (AnalogOut, BtnLevels[SelBtn]);
 
}
void loop()
{
ScanBtns();
delay(10);
}
 

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

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

  }
}
}
 
 
 
void unsetOther(int excludePin)
{
for  (int i=14; i <= 18; i++)
    {
    if (i != excludePin)
        pinMode(i, INPUT);
        digitalWrite(i,HIGH); 
    } 
 
analogWrite (AnalogOut, BtnLevels[excludePin]);
Serial.println(BtnLevels[excludePin]);  
}




TX  Hobby King 2.4Ghz 6Ch  :
inside.jpg?height=300&width=400


rtl2.jpg?height=300&width=400


stab.jpg?height=300&width=400
 
 


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

Comments

  • 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 kozin@mail.ru

  • Hi Charles

    i can produce one this

    rtl2.jpg?height=300&width=400
    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 http://forum.rcdesign.ru/blogs/99365/blog14414.html#comments
    Переключатель режимов ардупилота - Дневники - 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: http://www.rcgroups.com/forums/showthread.php?t=1515226

    or would it be too many pins used for the features (analog or digital)

    http://www.rcgroups.com/forums/showatt.php?attachmentid=5183917&d=1348598436
This reply was deleted.