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

  • its no commercial forum i cant show price here

    please all details by email

  • 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
  • Comment by Alexey Kozin just now Delete Comment

    that's cost parts for me

    psb 5$

    atmega328p 4$

    resonator 1$

    5 tactile buttons 3$

    5 smd 0603 Leds 3$

    other 3$

    ---------------------

    six button and led may be installed externaly on the body of tx near trottle stick for faster access to manual mode

    the next I wanted to do - add a beeper to dialtone and alarm warning of a low battery HК 6сh TX

  • small modification for six buttons

    /*
    s1 - s6 & LEDS connected to analog pins 1-6
    its numbers from 14 to 19


    */

    #define AnalogOut 10 // PWM out

    int SelBtn = 14; // default
    int BtnLevels[20];


    void setup()
    {

    Serial.begin(9600);

    //5 of 6 modes

    BtnLevels[14] = 0;
    BtnLevels[15] = 51;
    BtnLevels[16] = 102;
    BtnLevels[17] = 153;
    BtnLevels[18] = 204;
    BtnLevels[19] = 255;


    //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 <= 19; 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 <= 19; i++)
    {
    if (i != excludePin)
    pinMode(i, INPUT);
    digitalWrite(i,HIGH);
    }

    analogWrite (AnalogOut, BtnLevels[excludePin]);
    Serial.println(BtnLevels[excludePin]);
    }

  • Moderator

    Most Excellent!  Is there a reason you made it with 5 buttons instead of 6?

  • Cool hack.  That's what I call "getting the most out of your hardware".  

  • the chematic shows three LC filter on the output, but with

    / / force pwm
    TCCR1B = 0x01;

    two are already excessive

  • This switch may be assembled from standard mini - arduino board using external LEDs and buttons. I can send a printed circuit board or welded unit, but international shipping will cost more

This reply was deleted.