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



schematic




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  :




 
 


PSB Layout & chematic download

Views: 4034


Developer
Comment by Kabir on October 15, 2012 at 3:32am

can I has one????? 

Comment by Alexey Kozin on October 15, 2012 at 4:15am

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

Comment by Alexey Kozin on October 15, 2012 at 4:35am

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

/ / force pwm
TCCR1B = 0x01;

two are already excessive

Comment by Charles lakins on October 15, 2012 at 10:11am

how much for a completed board?

Comment by Todd Hill on October 15, 2012 at 11:56am

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

Comment by Charles lakins on October 15, 2012 at 12:14pm

im presently going this route for a seamless install by building my own

http://myfavoritestripper.blogspot.ca/2012/09/ardupilot-tx-mode-swi...

but i love the interface you have


Moderator
Comment by Mark Harrison on October 15, 2012 at 12:28pm

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

Comment by Charles lakins on October 15, 2012 at 1:57pm

i like the idea as i could incorporate it into my groundstation panel that runs my flightstick using an arduino too and runs through my trainer port

i wouldnt have to crack open my radio

Comment by Peter Meister on October 15, 2012 at 2:50pm

Very slick!

Comment by Alexey Kozin on October 15, 2012 at 8:33pm

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]);
}

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service