utility DigitalRadio configure chanel to range1000-2000 ms. /* 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 buttonBtnLevels[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 :
|
You need to be a member of diydrones to add comments!
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
Looks awesome Alexey!
I'll buy one if you ever produce them for sale :)
http://youtu.be/S5TCgGjUu7M
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)