The Arduino Project Begins!

Graphics Cards, Sound Cards, Joysticks, Computers, etc. Ask or advise here!

The Arduino Project Begins!

Postby OldAirmail » Sun Jul 24, 2016 6:05 pm

The Arduino Project Begins!

Short version - You can do a lot for cool stuff, very easily, and very cheaply, with Arduino.
The long version - go to this post for more info - The poor mans sim pit


(missing sections)


Enter the Arduino

Arduinos' are like small building blocks, they can do many things, and do them in a simple manner. As with building blocks, you can build a skyscraper if you want too. Think of Michelangelo, a block of stone, a hammer, a chisel. The rest is up to you (without all that heavy pounding :D ).

Using them in a flight sim panel is pretty simple though, and compared to the dedicated controller boards they're VERY, VERY cheap. Figure $5 to $12 each.

These are the three that I received today. At least two will be used in projects.

Image Image


What does it do?
[youtube]http://www.youtube.com/watch?v=5F054MNB1QI[/youtube]

Among other things, it can imitate a game controller that flight sims would recognize. It can turn LEDs on and off to let you know that your fuel is low or that your wheels are up. It can even make, or play back, sounds i.e. -"PULL UP, PULL UP!".

It can, and has, been made to make animated flight instruments. Use them to make a whole flight deck, if you have the time & money.

[youtube]http://www.youtube.com/watch?v=IqPUGcAwAkg[/youtube] . . . . [youtube]http://www.youtube.com/watch?v=3u-K7XZ4SQs[/youtube]

[youtube]http://www.youtube.com/watch?v=yqZbCH8iJ4M[/youtube] . . . . [youtube]http://www.youtube.com/watch?v=qP_nC5G-JfU[/youtube]

(missing sections)
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The Arduino Project Begins!

Postby Roypcox » Mon Jul 25, 2016 10:12 am

Great info thanks so much for sharing.
Roypcox
1st Lieutenant
1st Lieutenant
 
Posts: 412
Joined: Sun Apr 20, 2014 6:17 am

Re: The Arduino Project Begins!

Postby Sprocket » Mon Jul 25, 2016 11:24 am

:whistle:
Hi OAM..I'll give you bit of a head start..or a taste of what you are getting yourself into. :D

I love Arduino, and have used Arduino on many of my projects through the years. In May of 2015 I built a GA Radio stack, for the Mega 2560, utilising "Jim's FS2Link."

Following is the sketch (code) I put together for my radio. More than a month's work just in the code.
Got it all working on the bench, but never got so far as to put it all in a housing. What put me off really is the size of my 7 seg readouts, making the whole radio bigger than my monitor.

For what its worth: One of the major obstacles I found, is that of "lagging" response between FS and the Arduino. If the code is clumsy, the Arduino wastes time, (millisecs).

Jan

//Jan_Radio_16
// General: There are 6 Led modules designated 0 to 5
// MODULE 0 = Com 1+2 Active - (5 Digits) -- MODULE 1 = Com 1+2 Standby - (5 Digits) - >
// >AO low selects Com1Nav1 -- A1 low selects Com2Nav2
// MODULE 2 = Nav 1+2 Active - (5 Digits) -- MODULE 3 = Nav 1+2 Standby - (5 Digits) - >

// Module 4 = ADF - 5 Digits -- Module 5 = Transponder - 4 Digits

//There are 5 rotary encoders with push switch: QuadA for setting MODULE 1 Push/release switch to select Khz or Mhz - Pin A5
// QuadB for setting MODULE 3 Push/release switch to select Khz or Mhz - pin A6
// QuadC for setting MODULE 4 ADF - Pin A3
// QuadD for setting MODULE 5 XPNDR -Pin A4


#include "math.h"
#include "Quadrature.h"
#include "LedControl.h" // This Library is required to drive the MAX7219 7 segment LED displays.
//led_Display_1 is the variable name of my set of displays chained
LedControl led_Display_1 = LedControl(22,24,23,8); //together running off of pins 22,24,23. Pin 22 is the DataOut, Pin 23 is
//Load or CS, and Pin 24 is clock. The 8 is for how many displays you have
// in the chain.
Quadrature quad1(2, 3);
Quadrature quad2(4, 5);
Quadrature quad3(6, 7);
Quadrature quad4(8, 9);
Quadrature quad5(10,11);


int CodeIn; // used on all serial reads from Jim's code
//int KpinNo;
//int Koutpin;
//int pinNo;
//int doutpin;
int Count; // This variable used in loops in the EQUALS() function DO NOT REMOVE
//int inPin;
//int outPin;
//*************************ADF Buttons and LEDS******************************

int ADFbuttonPin = A3; // the pin that the ADF pushbutton is attached to
int ADFbuttonPushCounter = 1; // counter for the number of button presses- initialised to 1, so we can come back from 4th press straitgh to 1 again.
int ADFbuttonState = 1; // current state of the button
int ADFlastButtonState = 1; // previous state of the button

int ADFledPin1; //22 pin for the .1Khz indicator LED
int ADFledPin2; //23 pin for the 1Khz indicator LED
int ADFledPin3; // 24 pin for the 10Khz indicator LED
int ADFledPin4 ; // 25 pin for the 100Khz indicator LED

//*************************Transponder Buttons and LEDS***********************

int XPDRbuttonPin = A4; // the pin that the Transponder pushbutton is attached to
int XPDRbuttonPushCounter = 1; // counter for the number of button presses- initialised to 1, so we can come back from 4th press straitgh to 1 again.
int XPDRbuttonState = 1; // current state of the button
int XPDRlastButtonState = 1; // previous state of the button

int XPDRledPin1 = 30; // pin for the 1st Digit indicator LED
int XPDRledPin2 = 31; // pin for the 2nd Digit indicator LED
int XPDRledPin3 = 32; // pin for the 3rd Digit indicator LED
int XPDRledPin4 = 33; // pin for the 4th Digit indicator LED

//****************************************************************************




String Digit;
String QuadAup;
String QuadAdown;
String QuadBup;
String QuadBdown;
String QuadCup;
String QuadCdown;
String QuadDup;
String QuadDdown;
String QuadEup;
String QuadEdown;


//*************************************************************************************************
int Com1Active[6]; // Hopefully all of these variable names are mostly obvious.
int Com1StdBy[6]; // They will be used to store the extractions in array format.
int Nav1Active[5]; // The [n] with a number in it tells the arduino to make an array of the size n
int Nav1StdBy[5]; // The reason I store the information in arrays is to be able to display it without
int Com2Active[5]; // delay.
int Com2StdBy[5]; //
int Nav2Active[5]; //
int Nav2StdBy[5]; //
int ADF[5]; //
int Transponder[4]; //
int DME1[4]; //
int DME2[4];

long Xold1;// the first encoder "old" reading
long Xold2;// the second encoder "old" reading
long Xold3;// the third encoder "old" reading
long Xold4;// the fourth encoder "old" reading
long Xold5;// the fith encoder "old" reading

void setup()
{

//The MAX72XX is in power-saving mode on startup, we have to do a wakeup call
delay (100);
led_Display_1.shutdown(0,false); // I have 6 displays, these start them up
delay (100); // I put the delay in so they all dont start drawing
led_Display_1.shutdown(1,false); // current at the same time.
delay (100);
led_Display_1.shutdown(2,false);
delay (100);
led_Display_1.shutdown(3,false);
delay (100);
led_Display_1.shutdown(4,false);
delay (100);
led_Display_1.shutdown(5,false);

// Set the brightness to a lower than medium values
led_Display_1.setIntensity(0,8);
led_Display_1.setIntensity(1,8);
led_Display_1.setIntensity(2,8);
led_Display_1.setIntensity(3,8);
led_Display_1.setIntensity(4,8);
led_Display_1.setIntensity(5,8);


pinMode(A0, INPUT_PULLUP); //When A0 = Switched low, Com1 and Nav1 is selected for display on Module 0, 1 , 2 ,and 3
pinMode(A1, INPUT_PULLUP); //When A1 = Switched low, Com2 and Nav2 is selected for display on Module 0, 1 , 2 ,and 3
pinMode(A2, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
pinMode(A4, INPUT_PULLUP);
pinMode(A5, INPUT_PULLUP);
pinMode(A6, INPUT_PULLUP); //Pin for Quad 2 switch .. Nav Mhz/Khz select
pinMode(A7, INPUT_PULLUP);
pinMode(A8, INPUT_PULLUP); // Com1+2 - Stby x Active swop
pinMode(A9, INPUT_PULLUP); // Nav1+2 - Stby x Active swop
pinMode(A10, INPUT_PULLUP);

pinMode(A14, INPUT_PULLUP);
pinMode(A15, INPUT_PULLUP);

pinMode(ADFledPin1, OUTPUT); // declare LED as output
pinMode(ADFledPin2, OUTPUT);
pinMode(ADFledPin3, OUTPUT); // declare LED as output
pinMode(ADFledPin4, OUTPUT);

pinMode(XPDRledPin1, OUTPUT); // declare LED as output
pinMode(XPDRledPin2, OUTPUT);
pinMode(XPDRledPin3, OUTPUT); // declare LED as output
pinMode(XPDRledPin4, OUTPUT);

Serial.begin(115200);

} //end of setup

void loop(){

SwitchPositions_A0_A1();

if (Serial.available())
{
CodeIn = getChar();
if (CodeIn == '=')
{
EQUALS();
}
}

//******************* Rotary Encoders engine ***********************


long X1 =(quad1.position()); // divide by 2 for half cycle encoders
if (X1 != Xold1){
if (X1 > Xold1) {Serial.println(QuadAup);} else {Serial.println(QuadAdown);}
Xold1 = X1;
}//end of quad1 read

long X2 =(quad2.position()); // divide by 2 for half cycle encoders
if (X2 != Xold2){
if (X2 > Xold2) {Serial.println(QuadBup);} else {Serial.println(QuadBdown);}
Xold2 = X2;
}//end of quad2 read

long X3 =(quad3.position()); // divide by 2 for half cycle encoders
if (X3 != Xold3){
if (X3 > Xold3) {Serial.println(QuadCup);} else {Serial.println(QuadCdown);}
Xold3 = X3;
}//end of quad3 read

long X4 =(quad4.position()); // divide by 2 for half cycle encoders
if (X4 != Xold4){
if (X4 > Xold4) {Serial.println(QuadDup);} else {Serial.println(QuadDdown);}
Xold4 = X4;
}//end of quad4 read

long X5 =(quad5.position()); // divide by 2 for half cycle encoders
if (X5 != Xold5){
if (X5 > Xold5) {Serial.println(QuadEup);} else {Serial.println(QuadEdown);}
Xold5 = X5;
}//end of quad5 read


//*******************ADF button engine ***********************

ADFbuttonState = digitalRead(ADFbuttonPin); // read the pushbutton input pin:
if (ADFbuttonState != ADFlastButtonState) // compare the buttonState to its previous state
{
if (ADFbuttonState ==LOW){
delay(50);
ADFbuttonPushCounter++; // if the state has changed, increment the counter
}{
if (ADFbuttonPushCounter == 1)
Serial.println ("ADFone");
}{
if (ADFbuttonPushCounter ==2)
Serial.println ("ADFtwo");
}{
if (ADFbuttonPushCounter == 3)
Serial.println ("ADFthree");
}{
if (ADFbuttonPushCounter == 4)
Serial.println ("ADFfour");
}delay(50);
{
if (ADFbuttonPushCounter == 5) { //Reset Counter back to count 1
ADFbuttonPushCounter =1; } //
ADFlastButtonState = ADFbuttonState;}
}

//*********************TRANSPONDER button engine*****************

XPDRbuttonState = digitalRead(XPDRbuttonPin); // read the pushbutton input pin:
if (XPDRbuttonState != XPDRlastButtonState) // compare the buttonState to its previous state
{
if (XPDRbuttonState ==LOW){
delay(50);
XPDRbuttonPushCounter++; // if the state has changed, increment the counter
}{
if (XPDRbuttonPushCounter == 1)
Serial.println ("XPDRone");
}{
if (XPDRbuttonPushCounter ==2)
Serial.println ("XPDRtwo");
}{
if (XPDRbuttonPushCounter == 3)
Serial.println ("XPDRthree");
}{
if (XPDRbuttonPushCounter == 4)
Serial.println ("XPDRfour");
}delay(50);
{
if (XPDRbuttonPushCounter == 5) { //Reset Counter back to count 1
XPDRbuttonPushCounter =1; } //
XPDRlastButtonState = XPDRbuttonState;}
}

} //end of void loop


//*********************************************************
//*********************************************************
char getChar()// Get a character from the serial buffer
{
while(Serial.available() == 0); // wait for data
return((char)Serial.read());
}


//********* select COM1 and NAV1 ************//
void SwitchPositions_A0_A1() //SelectPosition A0 for COM1/NAV1 -- A1 for COM2/NAV2

{
if (digitalRead(A0) == LOW)

{
if (digitalRead (A5) == LOW ) // Switch = tied high..Push to make low to change the Mhz setting
{
QuadAup = "A02"; //Decrement COM by one Mhz === Encoder 1
QuadAdown = "A01"; //Increment COM by one Mhz

led_Display_1.setDigit(0,7,Com1Active[0],false);
led_Display_1.setDigit(0,6,Com1Active[1],false);
led_Display_1.setDigit(0,5,Com1Active[2],true);
led_Display_1.setDigit(0,4,Com1Active[3],false);
led_Display_1.setDigit(0,3,Com1Active[4],false);
led_Display_1.setDigit(0,2,Com1Active[5],false);


led_Display_1.setDigit(1,7,Com1StdBy[0],false);
led_Display_1.setDigit(1,6,Com1StdBy[1],false);
led_Display_1.setDigit(1,5,Com1StdBy[2],true);
led_Display_1.setDigit(1,4,Com1StdBy[3],false);
led_Display_1.setDigit(1,3,Com1StdBy[4],false);
led_Display_1.setDigit(1,2,Com1StdBy[5],false);
}

else if (digitalRead (A5) == HIGH ) //Switch is NOT PUSHED
{
QuadAup = "A04"; //Increment COM by 25 Khz === Encoder 1
QuadAdown = "A03"; //Decrement COM by 25 Khz

led_Display_1.setDigit(0,7,Com1Active[0],false);
led_Display_1.setDigit(0,6,Com1Active[1],false);
led_Display_1.setDigit(0,5,Com1Active[2],true);
led_Display_1.setDigit(0,4,Com1Active[3],false);
led_Display_1.setDigit(0,3,Com1Active[4],false);

led_Display_1.setDigit(1,7,Com1StdBy[0],false);
led_Display_1.setDigit(1,6,Com1StdBy[1],false);
led_Display_1.setDigit(1,5,Com1StdBy[2],true);
led_Display_1.setDigit(1,4,Com1StdBy[3],false);
led_Display_1.setDigit(1,3,Com1StdBy[4],false);
}
if (digitalRead(A8) == LOW) //Swop
{
Serial.println ("A06"); //Com1 standby switch
}

if (digitalRead (A6) == LOW )
{
QuadBup = "A14"; //Increment NAV1 by one Mhz
QuadBdown = "A13"; //Decrement NAV1 by one Mhz

led_Display_1.setDigit(2,7,Nav1Active[0],false);
led_Display_1.setDigit(2,6,Nav1Active[1],false);
led_Display_1.setDigit(2,5,Nav1Active[2],true);
led_Display_1.setDigit(2,4,Nav1Active[3],false);
led_Display_1.setDigit(2,3,Nav1Active[4],false);


led_Display_1.setDigit(3,7,Nav1StdBy[0],false);
led_Display_1.setDigit(3,6,Nav1StdBy[1],false);
led_Display_1.setDigit(3,5,Nav1StdBy[2],true);
led_Display_1.setDigit(3,4,Nav1StdBy[3],false);
led_Display_1.setDigit(3,3,Nav1StdBy[4],false);

}
else if (digitalRead(A6) == HIGH )
{
QuadBup = "A16"; //Increment NAV1 by one 25Khz
QuadBdown = "A15"; //Decrement NAV1 by one 25Khz

led_Display_1.setDigit(2,7,Nav1Active[0],false);
led_Display_1.setDigit(2,6,Nav1Active[1],false);
led_Display_1.setDigit(2,5,Nav1Active[2],true);
led_Display_1.setDigit(2,4,Nav1Active[3],false);
led_Display_1.setDigit(2,3,Nav1Active[4],false);


led_Display_1.setDigit(3,7,Nav1StdBy[0],false);
led_Display_1.setDigit(3,6,Nav1StdBy[1],false);
led_Display_1.setDigit(3,5,Nav1StdBy[2],true);
led_Display_1.setDigit(3,4,Nav1StdBy[3],false);
led_Display_1.setDigit(3,3,Nav1StdBy[4],false);

if (digitalRead(A9) == LOW)
{
Serial.println ("A18"); //Nav1 standby switch

}
}
}


//********************************************** End Select Com1 Nav1 ****************************************


//***************************************** Select Com2 Nav 2 *******************************************


else if (digitalRead (A1) == LOW)

{
if (digitalRead (A5) == LOW )
{
QuadAup = "A08"; //COM2 Mhz Up
QuadAdown = "A07"; //COM2 Mhz Dwn

led_Display_1.setDigit(0,7,Com2Active[0],false);
led_Display_1.setDigit(0,6,Com2Active[1],false);
led_Display_1.setDigit(0,5,Com2Active[2],true);
led_Display_1.setDigit(0,4,Com2Active[3],false);
led_Display_1.setDigit(0,3,Com2Active[4],false);


led_Display_1.setDigit(1,7,Com2StdBy[0],false);
led_Display_1.setDigit(1,6,Com2StdBy[1],false);
led_Display_1.setDigit(1,5,Com2StdBy[2],true);
led_Display_1.setDigit(1,4,Com2StdBy[3],false);
led_Display_1.setDigit(1,3,Com2StdBy[4],false);
}
else if (digitalRead (A5) == HIGH )
{
QuadAup = "A10"; //COM2 Khz Up
QuadAdown = "A09"; //COM2 Khz Dwn

led_Display_1.setDigit(0,7,Com2Active[0],false);
led_Display_1.setDigit(0,6,Com2Active[1],false);
led_Display_1.setDigit(0,5,Com2Active[2],true);
led_Display_1.setDigit(0,4,Com2Active[3],false);
led_Display_1.setDigit(0,3,Com2Active[4],false);


led_Display_1.setDigit(1,7,Com2StdBy[0],false);
led_Display_1.setDigit(1,6,Com2StdBy[1],false);
led_Display_1.setDigit(1,5,Com2StdBy[2],true);
led_Display_1.setDigit(1,4,Com2StdBy[3],false);
led_Display_1.setDigit(1,3,Com2StdBy[4],false);
}
if (digitalRead(A8) == LOW)
{
Serial.println ("A12"); //Com2 standby switch
}
if (digitalRead (A3) == LOW )
{
QuadBup = "A20"; //NAV2 Mhz Up
QuadBdown = "A19"; //NAV2 Mhz Dwn

led_Display_1.setDigit(2,7,Nav2Active[0],false);
led_Display_1.setDigit(2,6,Nav2Active[1],false);
led_Display_1.setDigit(2,5,Nav2Active[2],true);
led_Display_1.setDigit(2,4,Nav2Active[3],false);
led_Display_1.setDigit(2,3,Nav2Active[4],false);


led_Display_1.setDigit(3,7,Nav2StdBy[0],false);
led_Display_1.setDigit(3,6,Nav2StdBy[1],false);
led_Display_1.setDigit(3,5,Nav2StdBy[2],true);
led_Display_1.setDigit(3,4,Nav2StdBy[3],false);
led_Display_1.setDigit(3,3,Nav2StdBy[4],false);

}

else if (digitalRead(A3) == HIGH )
{
QuadBup = "A22"; //NAV2 Khz Up
QuadBdown = "A21"; //NAV2 Khz Dwn

led_Display_1.setDigit(2,7,Nav2Active[0],false);
led_Display_1.setDigit(2,6,Nav2Active[1],false);
led_Display_1.setDigit(2,5,Nav2Active[2],true);
led_Display_1.setDigit(2,4,Nav2Active[3],false);
led_Display_1.setDigit(2,3,Nav2Active[4],false);


led_Display_1.setDigit(3,7,Nav2StdBy[0],false);
led_Display_1.setDigit(3,6,Nav2StdBy[1],false);
led_Display_1.setDigit(3,5,Nav2StdBy[2],true);
led_Display_1.setDigit(3,4,Nav2StdBy[3],false);
led_Display_1.setDigit(3,3,Nav2StdBy[4],false);

if (digitalRead(A9) == LOW) // Nav swop
{
Serial.println ("A24"); //Nav2 standby switch
}
}

}
//***************************************** End Com2 Nav 2 *******************************************

//******** ADF ******************************************************
{
{
//**********************ADF digit indicator Led's Engine **************************
if (ADFbuttonPushCounter==1)
digitalWrite (ADFledPin1,HIGH); // We need to indicate the ADF digit that is active for changing.
if (ADFbuttonPushCounter!=1) // For this we mount an LED under each digit on the panel, and light the
digitalWrite (ADFledPin1,LOW); // relevant one as an indicator.

if (ADFbuttonPushCounter== 2)
digitalWrite (ADFledPin2,HIGH);
if (ADFbuttonPushCounter!= 2)
digitalWrite (ADFledPin2,LOW);

if (ADFbuttonPushCounter==3)
digitalWrite (ADFledPin3,HIGH);
if (ADFbuttonPushCounter!=3)
digitalWrite (ADFledPin3,LOW);

if (ADFbuttonPushCounter== 4)
digitalWrite (ADFledPin4,HIGH);
if (ADFbuttonPushCounter!= 4)
digitalWrite (ADFledPin4,LOW);
}

//************************--ADF Encoder QuadC--***********************************
{
if (ADFbuttonPushCounter == 1 )
QuadCup = "A28"; // inc ADF 0.1 Khz Up
if (ADFbuttonPushCounter == 1 )
QuadCdown = "A32"; // dec ADF 0.1 Khz Dwn

led_Display_1.setDigit(4,7,ADF[0],false);
led_Display_1.setDigit(4,6,ADF[1],false);
led_Display_1.setDigit(4,5,ADF[2],false);
led_Display_1.setDigit(4,4,ADF[3],true);
led_Display_1.setDigit(4,3,ADF[4],false);
}
{

if (ADFbuttonPushCounter == 2 )
QuadCup = "A27"; //ADF 1 Khz Up
if (ADFbuttonPushCounter == 2 )
QuadCdown = "A31"; //ADF 1 Khz Dwn

led_Display_1.setDigit(4,7,ADF[0],false);
led_Display_1.setDigit(4,6,ADF[1],false);
led_Display_1.setDigit(4,5,ADF[2],false);
led_Display_1.setDigit(4,4,ADF[3],true);
led_Display_1.setDigit(4,3,ADF[4],false);

}
{

if (ADFbuttonPushCounter == 3 )
QuadCup = "A26"; //ADF 10 Khz Up
if (ADFbuttonPushCounter == 3 )
QuadCdown = "A30"; //ADF 10 Khz Dwn

led_Display_1.setDigit(4,7,ADF[0],false);
led_Display_1.setDigit(4,6,ADF[1],false);
led_Display_1.setDigit(4,5,ADF[2],false);
led_Display_1.setDigit(4,4,ADF[3],true);
led_Display_1.setDigit(4,3,ADF[4],false);

}
{

if (ADFbuttonPushCounter == 4 )
QuadCup = "A25"; //ADF 100 Khz Up
if (ADFbuttonPushCounter == 4 )
QuadCdown = "A29"; //ADF 100 Khz Dwn

led_Display_1.setDigit(4,7,ADF[0],false);
led_Display_1.setDigit(4,6,ADF[1],false);
led_Display_1.setDigit(4,5,ADF[2],false);
led_Display_1.setDigit(4,4,ADF[3],true);
led_Display_1.setDigit(4,3,ADF[4],false);

}
}

//********************************* End select ADF ***************************************

//******************************** Select Transponder ************************************

//**********************Transponder digit indicator Led's Engine **************************
{
if (XPDRbuttonPushCounter==1)
digitalWrite (XPDRledPin1,HIGH); // We need to indicate the XPDR digit that is active for changing.
if (XPDRbuttonPushCounter!=1) // For this we mount an LED under each digit on the panel, and light the
digitalWrite (XPDRledPin1,LOW); // relevant one as an indicator.

if (XPDRbuttonPushCounter== 2)
digitalWrite (XPDRledPin2,HIGH);
if (XPDRbuttonPushCounter!= 2)
digitalWrite (XPDRledPin2,LOW);

if (XPDRbuttonPushCounter==3)
digitalWrite (XPDRledPin3,HIGH);
if (XPDRbuttonPushCounter!=3)
digitalWrite (XPDRledPin3,LOW);

if (XPDRbuttonPushCounter== 4)
digitalWrite (XPDRledPin4,HIGH);
if (XPDRbuttonPushCounter!= 4)
digitalWrite (XPDRledPin4,LOW);

//************************--Transponder Encoder QuadD--***********************************
{
if (XPDRbuttonPushCounter == 1 )
QuadDup = "A34"; // increase XPDR 1st Digit
if (XPDRbuttonPushCounter == 1 )
QuadDdown = "A38"; // decrease XPDR 1st Digit

led_Display_1.setDigit(5,7,Transponder[0],false);
led_Display_1.setDigit(5,6,Transponder[1],false);
led_Display_1.setDigit(5,5,Transponder[2],false);
led_Display_1.setDigit(5,4,Transponder[3],false);
}
{
if (XPDRbuttonPushCounter == 2 )
QuadDup = "A35"; // increase XPDR 2nd Digit
if (XPDRbuttonPushCounter == 2 )
QuadDdown = "A39"; //decrease XPDR 2nd Digit

led_Display_1.setDigit(5,7,Transponder[0],false);
led_Display_1.setDigit(5,6,Transponder[1],false);
led_Display_1.setDigit(5,5,Transponder[2],false);
led_Display_1.setDigit(5,4,Transponder[3],false);
}
{

if (XPDRbuttonPushCounter == 3 )
QuadDup = "A36"; //increase XPDR 3rd Digit
if (XPDRbuttonPushCounter == 3 )
QuadDdown = "A40"; //decrease XPDR 3rd Digit

led_Display_1.setDigit(5,7,Transponder[0],false);
led_Display_1.setDigit(5,6,Transponder[1],false);
led_Display_1.setDigit(5,5,Transponder[2],false);
led_Display_1.setDigit(5,4,Transponder[3],false);
}
{
if (XPDRbuttonPushCounter == 4 )
QuadDup = "A37"; //increase XPDR 4th Digit
if (XPDRbuttonPushCounter == 4 )
QuadDdown = "A41"; //decrease XPDR 4th Digit

led_Display_1.setDigit(5,7,Transponder[0],false);
led_Display_1.setDigit(5,6,Transponder[1],false);
led_Display_1.setDigit(5,5,Transponder[2],false);
led_Display_1.setDigit(5,4,Transponder[3],false);
}
}//end of XPDR


//******************** DME ***************************
{
void SwitchPositions_A14_A15();

if (digitalRead(A14) == LOW)
{
led_Display_1.setDigit(5,3,DME1[0],false);
led_Display_1.setDigit(5,2,DME1[1],false);
led_Display_1.setDigit(5,1,DME1[2],true);
led_Display_1.setDigit(5,0,DME1[3],false);
}
if (digitalRead(A15) == LOW)

{
led_Display_1.setDigit(5,3,DME2[0],false);
led_Display_1.setDigit(5,2,DME2[1],false);
led_Display_1.setDigit(5,1,DME2[2],true);
led_Display_1.setDigit(5,0,DME2[3],false);
}
} //end of DME

} // Goes far up do not remove


//***************************************** End select Transponder ******************************************


//************************************************************************************************************
// Now let's read from the FS and display the values on the modules
//************************************************************************************************************


void EQUALS(){ // The first identifier was "="
CodeIn = getChar(); // Get another character
switch(CodeIn)
{
case 'A': //COM1 Active Module 0
Count = 0;
while (Count <6) // 5 Five digits to store in the Com1Active Freq
{ //
Digit = ""; // Clear Digit
Digit += getChar(); // Get a character put it in the String "Digit"
if (Digit ==".") // ****** This looks for the "." *************
{
Digit = ""; // If we find the "." we clear it and get the next digit
Digit += getChar(); // Because we know where the "." always goes.
}
Com1Active[Count] = Digit.toInt(); // Turn String Digit into an Integer and store it in the Array for later
Count++; // add one to the count
}

{
led_Display_1.setDigit(0,7,Com1Active[0],false);
led_Display_1.setDigit(0,6,Com1Active[1],false);
led_Display_1.setDigit(0,5,Com1Active[2],true);
led_Display_1.setDigit(0,4,Com1Active[3],false);
led_Display_1.setDigit(0,3,Com1Active[4],false);
led_Display_1.setDigit(0,2,Com1Active[5],false);
}

break;

case 'B': //COM1 Standby Module 1
Count = 0;
while (Count <6)
{
Digit = "";
Digit += getChar();
if (Digit ==".")
{
Digit = "";
Digit += getChar();
}
Com1StdBy[Count] = Digit.toInt();
Count++;
}
{
led_Display_1.setDigit(1,7,Com1StdBy[0],false);
led_Display_1.setDigit(1,6,Com1StdBy[1],false);
led_Display_1.setDigit(1,5,Com1StdBy[2],true);
led_Display_1.setDigit(1,4,Com1StdBy[3],false);
led_Display_1.setDigit(1,3,Com1StdBy[4],false);
led_Display_1.setDigit(1,2,Com1StdBy[5],false);

break;


case 'C': //COM2 Active Module 0 when switched here
Count = 0;
while (Count <5)
{
Digit = "";
Digit += getChar();
if (Digit ==".")
{
Digit = "";
Digit += getChar();
}
Com2Active[Count] = Digit.toInt();
Count++;
}

{
led_Display_1.setDigit(0,7,Com2Active[0],false);
led_Display_1.setDigit(0,6,Com2Active[1],false);
led_Display_1.setDigit(0,5,Com2Active[2],true);
led_Display_1.setDigit(0,4,Com2Active[3],false);
led_Display_1.setDigit(0,3,Com2Active[4],false);
}

break;

case 'D': //COM2 Standby Module 1 when switched here
Count = 0;
while (Count <5)
{
Digit = "";
Digit += getChar();
if (Digit ==".")
{
Digit = "";
Digit += getChar();
}
Com2StdBy[Count] = Digit.toInt();
Count++;
}

{
led_Display_1.setDigit(1,7,Com2StdBy[0],false);
led_Display_1.setDigit(1,6,Com2StdBy[1],false);
led_Display_1.setDigit(1,5,Com2StdBy[2],true);
led_Display_1.setDigit(1,4,Com2StdBy[3],false);
led_Display_1.setDigit(1,3,Com2StdBy[4],false);
}

break;


case 'E': // Nav1 Active Module 2
Count = 0;
while (Count <5)
{
Digit = "";
Digit += getChar();
if (Digit ==".")
{
Digit = "";
Digit += getChar();
}
Nav1Active[Count] = Digit.toInt();
Count++;
}

{
led_Display_1.setDigit(2,7,Nav1Active[0],false);
led_Display_1.setDigit(2,6,Nav1Active[1],false);
led_Display_1.setDigit(2,5,Nav1Active[2],true);
led_Display_1.setDigit(2,4,Nav1Active[3],false);
led_Display_1.setDigit(2,3,Nav1Active[4],false);
}

break;

case 'F': // Nav1 Standby Module 3
Count = 0;
while (Count <5)
{
Digit = "";
Digit += getChar();
if (Digit ==".")
{
Digit = "";
Digit += getChar();
}
Nav1StdBy[Count] = Digit.toInt();
Count++;
}

{
led_Display_1.setDigit(3,7,Nav1StdBy[0],false);
led_Display_1.setDigit(3,6,Nav1StdBy[1],false);
led_Display_1.setDigit(3,5,Nav1StdBy[2],true);
led_Display_1.setDigit(3,4,Nav1StdBy[3],false);
led_Display_1.setDigit(3,3,Nav1StdBy[4],false);
}
}
break;

case 'G': // Nav2 Active Module 2 when switched here
Count = 0;
while (Count <5)
{
Digit = "";
Digit += getChar();
if (Digit ==".")
{
Digit = "";
Digit += getChar();
}
Nav2Active[Count] = Digit.toInt();
Count++;
}

{
led_Display_1.setDigit(2,7,Nav2Active[0],false);
led_Display_1.setDigit(2,6,Nav2Active[1],false);
led_Display_1.setDigit(2,5,Nav2Active[2],true);
led_Display_1.setDigit(2,4,Nav2Active[3],false);
led_Display_1.setDigit(2,3,Nav2Active[4],false);
}

break;

case 'H': // Nav2 Standby Module3 when switched here
Count = 0;
while (Count <5)
{
Digit = "";
Digit += getChar();
if (Digit ==".")
{
Digit = "";
Digit += getChar();
}
Nav2StdBy[Count] = Digit.toInt();
Count++;
}

{
led_Display_1.setDigit(3,7,Nav2StdBy[0],false);
led_Display_1.setDigit(3,6,Nav2StdBy[1],false);
led_Display_1.setDigit(3,5,Nav2StdBy[2],true);
led_Display_1.setDigit(3,4,Nav2StdBy[3],false);
led_Display_1.setDigit(3,3,Nav2StdBy[4],false);
}

break;

case 'I': // ADF Module 4
Count = 0;
while (Count <5)
{
Digit = "";
Digit += getChar();
if (Digit ==".")
{
Digit = "";
Digit += getChar();
}
ADF[Count] = Digit.toInt();
Count++;
}

{

led_Display_1.setDigit(4,7,ADF[0],false);
led_Display_1.setDigit(4,6,ADF[1],false);
led_Display_1.setDigit(4,5,ADF[2],false);
led_Display_1.setDigit(4,4,ADF[3],true);
led_Display_1.setDigit(4,3,ADF[4],false);

}

break;


case 'J': // Transponder Module 5
Count = 0;
while (Count <4) //4
{
Digit = "";
Digit += getChar();

Transponder[Count] = Digit.toInt();
Count++;
}

{
led_Display_1.setDigit(5,7,Transponder[0],false);
led_Display_1.setDigit(5,6,Transponder[1],false);
led_Display_1.setDigit(5,5,Transponder[2],false);
led_Display_1.setDigit(5,4,Transponder[3],false);
}

break;


case 'K': // DME Module

Count = 0;
while (Count < 4)
{
Digit = "";
Digit += getChar();
if (Digit ==".")
{
Digit = "";
Digit += getChar();
}
DME1[Count] = Digit.toInt();
Count++;
}

{ // Since Xpdr only uses 4 digits, we use the rest of module 5 for the DME
led_Display_1.setDigit(5,3,DME1[0],false);
led_Display_1.setDigit(5,2,DME1[1],false);
led_Display_1.setDigit(5,1,DME1[2],true);
led_Display_1.setDigit(5,0,DME1[3],false);
}

break;
case 'L': // DME2
Count = 0;
while (Count < 4)
{
Digit = "";
Digit += getChar();
if (Digit ==".")
{
Digit = "";
Digit += getChar();
}
DME2[Count] = Digit.toInt();
Count++;
}

{
led_Display_1.setDigit(5,3,DME2[0],false);
led_Display_1.setDigit(5,2,DME2[1],false);
led_Display_1.setDigit(5,1,DME2[2],true);
led_Display_1.setDigit(5,0,DME2[3],false);
}

break;


}

}
User avatar
Sprocket
1st Lieutenant
1st Lieutenant
 
Posts: 309
Joined: Wed Oct 30, 2013 12:10 pm

Re: The Arduino Project Begins!

Postby OldAirmail » Tue Jul 26, 2016 10:17 pm

TL;DR

Thanks, Jan.

My first computer programming experience went something like this -

[youtube]http://www.youtube.com/watch?v=hShY6xZWVGE[/youtube]

Well..... Perhaps it was a little more primitive - like a Timex Sinclair 1000.

But it did provide me with a ton of useful experience. The most useful being that I shouldn't take out a large school loan to study programming. I'm good at some things. Not so good at others.


Over the decades, I did do a little programming, just for my own entertainment.

So, strangely enough, what you've written is familiar. Similar to a Spanish person being able to make some sense out of written Portuguese of Italian.

That's not to say that I could come up with anything even close to what you've done. But for the most part I can follow what you've done, making a bunch of assumptions as I go down the lines.

In short, although it's beyond me, it's GREAT! :D



Do keep an eye out for mistakes, I'm bound to make many of them.

But Arduino's are new to me, and I'm sure to many others. As I start to learn, and play around with the boards and the language needed to make them do as I want, perhaps others can take this journey with me.

If nothing else, maybe others will get a glimpse of what these boards can do.

I want to concentrate, at the moment, on simple flight sim boxes. I need to repair a Saitek Switch Panel, but new ideas are popping up every day.

What I learn, and do, may give another beginner the idea the they too could do the same thing.

OK, start reading



For those not familiar (as I am not fully, at this moment) with the various Arduino boards

Taking that simile of the Latin based languages being similar but different, and carrying it over to the Arduino hardware I want to explain a little of what I know.


BASICS
Arduino is an open-source electronic prototyping system. Arduino is also a "brand name". Check out their site - arduino.cc.

Arduino is "open source". That means that although the Arduino creators have established the essential standards, they don't try to restrict others from using those standards to make & sell similar units.

So one company or another may "follow the standards", but add a bit more memory. Another may make a "standard" Arduino compatible, but with faster components. Still another may build in new features.

Are you getting the idea? There is a brand name Arduino, and there are various Arduino clones.

The three that I bought, use the same programming even thought they have different features.

And because they ARE different in one way or another, they are not identical in pin distributions. Going from one to another can be confusing. But even then, there is a method to the madness.

Collectively, though, I'll call all of them Arduino.


Get 'em while they're hot!

I've bought three of them. Two small sized, because I'll need small sized boards when I do what I want to do. The third I bought as a kit.

IDUINO from Makers Life the Iduino Nano
Teensy 3.2 from PJRC
Arduino Mega 2560 UNO R3 sold as part of a kit from Amazon

Image


My advice is to pick a kit that looks interesting to you. The more parts the better. Just be careful, there are quite a few overpriced kits out there.

To be sure, the cheaper the kit, the cheap the components. But the whole point of getting a kit is to see if you'll be interested. So pay $30-$40. It'll be usable.



A way back I said that an Arduino is an open-source electronic prototyping system.

Really smart people can pull a bunch of electrical parts out of a drawer and make a perfectly useful, fully functional, flux capacitor.

For most of us though we make temporary assemblies of parts. And hope it works. We read the instructions a bit more closely, rearrange some wires, turn that diode the other way. And hope it works.

In short, we learn. And if you haven't been doing that for a long while, it's refreshingly fun.



No one says that you have to become an electrical engineer. Just have fun learning enough to make something that YOU want.

It doesn't have to go to the moon. It can be something as simple as having your mail box tell you that You have mail!

Or do something dull and uninteresting such as make your own switch box for $10-$15 that lets you start the engines, and raise the landing gear.

Can I do that right now? No.

But I already know enough to know that it isn't going to be hard OR expensive.
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The Arduino Project Begins!

Postby Sprocket » Wed Jul 27, 2016 6:32 am

..
I hope it is alright to put this here, but there is a "dedicated" site that deals solely with FS hardware.
http://www.mycockpit.org/forums/forum.php

and if you scroll further down, you'll find the dedicated Arduino and FS hardware sub-forum.
http://www.mycockpit.org/forums/arduino-cards-link2fs/

Here is where I learned on how to use "link2fs" and how to code for it. I like it for its simplicity, but you can also use FSUIPC otherwise.

Jan, ( and in the words of Fozzer.....still learning.... :D )
User avatar
Sprocket
1st Lieutenant
1st Lieutenant
 
Posts: 309
Joined: Wed Oct 30, 2013 12:10 pm

Re: The Arduino Project Begins!

Postby OldAirmail » Wed Jul 27, 2016 9:35 pm

DARN YOU TO HECK AND BACK! :evil:

You sent me off to the world of Arduinos and Magnetic compasses for the whole evening!



Yes, I've been too mycockpit.org over the years, but I've always been a few disconnects with mycockpit.

First, although there are a number of small projects, the emphasis has always seemed to be with LARGE commercial jet cockpits.


And even the small cockpit builds, take far more room than I have available.

On top of that I work for a living, so the time to build the Boeing 747-8, or the Airbus A380 of my dreams, isn't there. Not to mention that I have a wife, and you know how they are when you aren't spending money on them. :shifty:


And speaking of the plane of my dreams, it's usually something that lands on smaller airports, if it needs a runway at all.

Simply put, I have little interest in full blown cockpits such as this one from mycockpit.org, amazing as it may be.
Image

One last word - Arduino Cards & Link2FS, on mycockpit.org, looks like a GREAT flight sim resource.




Back to the point of the series.

BUT, a Magnetic compass! Hanging over the top of my monitor! :D

HECK YES! :dance:

[youtube]http://www.youtube.com/watch?v=drjUuMHZVe0[/youtube]


And that's where I've been for the evening, reading the posts in Magnetic compass build and code.

Researching stepper motors and Arduino stepper boards.

Now THAT'S something I find highly interesting. :D
Image



If this series goes anywhere, it'll be towards the smaller projects, because the denizens of Simviation, for whatever the reasons, might, just might, say "Hay, maybe I could make a small, inexpensive, switch panel. Or MAYBE, even a GPS panel".

In the end, if you check out Home Cockpits and Setups here on Simviation, you'll see that ermias is one of the very few ACTIVE posters. Simviators just aren't really interested in full blown simulators.

I, for one, would like to see a few more people interested in creating their own flight sim interface. Just a little here. Just a little there.



A word about cost

The cost of some flight sim interface boards, such as the GF-DIO (Digital Input/Output) Board
Image

I'm sure that this GoFlight board is a very nice board. It may even be used by a large number of "full cockpit" builders. I don't know.

BUT, at $279.99 each, I do know that I'll never be tempted to buy one.

There are, of course, many lower priced boards out there, aimed at the flight sim community. They usually start at $35 or more, and go up quickly.

But will someone invest $17 for an Arduino AND kit? - Elegoo UNO Project Basic Starter Kit with Tutorial and UNO R3 for Arduino

Image
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The Arduino Project Begins!

Postby OldAirmail » Sun Jul 31, 2016 2:20 pm

Some of the possibilities

There are a number of ways to control some functions on a flight sim. There's -
Flight sim panel controller software.
SPAD
SPAD.neXt
FSUIPC
Link2fs Multi

And lots of study on how to make the Arduino do what you want it to do to control a flight sim.


A solution
I'm not looking for the "easy way out", but if it takes more work than assigning buttons in FSX, then not too many people will be interested.

The answer comes from a two year old post in mycockpit.org - Flight Pro Yoke Joystick repair with Arduino Mega 2560 -- Arduino HID Joystick 8 axis 50 buttons

Read that last part again- Arduino HID Joystick 8 axis 50 buttons! :o

I haven't used it yet, but several people in that link have, and said it worked.

So, once programmed, this should make your Arduino instantly recognized by FS9, FSX, P3d, or ANY OTHER SOFTWARE that can use a USB/HID controller such as a joystick.



I'll still learn more about the Arduino, and programming it, but if anyone is out there and wants to star without me, go ahead. :clap:

The more that I learn, the more possibilities open up.
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5

Re: The Arduino Project Begins!

Postby OldAirmail » Mon Aug 01, 2016 10:26 pm

Jan (Sprocket) probably slapped his forehead and then had a good long laugh at the post above. :doh:

That's OK, I'm still learning. :lol: :lol: :lol:



K I S S

Keep It Simple Stupid


If anyone is following this journey, I hope that it's with the understanding that I'm young and foolish full of enthusiasm over a very low cost device that will let me have fun making things that would otherwise be VERY hard to make.


The mistake that I made in finding a “simple way" to make an HID/joystick/button controller, was in not doing some of the easy examples that come with the various Arduino boards.

In essence, I was stepping over a pot of gold on my way to becoming a prospector.


There are a number of ways to learn how to use one of the many Arduinos.

And it’s probably best to start with the included examples that came with the one that you bought. Alternately, you can go to the manufacturers website. Or if you’re a slow child like me, simply LOOK at the software that you use to program the Arduino - Arduino programmer software.

A few screen shots should tell the story of what I had right under my nose, but here's the Arduino Teensy instructions to make it a USB/HID device - Using USB Joystick


This picture is from the software that you use to load the program into the Arduino

Notice anything of interest?
Image



Complicated, so follow closely
Step 1 - Find the code in the sample
Step 2 - Download it to the Arduino

After you have it working the way that you want it too, it'll always be recognized as a HID controller. Unless you re-program it, of course.

Image


To make it as clear as possible - Once it's programmed and plugged in FS9/FSX/P3d/X-Plane will see this -

Image

There'll be a bit more, but that's it in a nutshell. You'll still have to attach buttons, or whatever, so you can set it up whatever way pleases you.

This was with a Teensy Arduino. Some of the others don't have the HID built in, and may need that program - Link2fs Multi.
.. .
Get the most out of your controls - SPAD.neXt

Image
. . . . . .Any time, any plane, any weather.
. . . . . . . . . . . . . Prepar3d V4
User avatar
OldAirmail
Major
Major
 
Posts: 4814
Joined: Sun Feb 17, 2013 3:06 pm
Location: Concrete, WA ICAO - 3W5


Return to Hardware

Who is online

Users browsing this forum: No registered users and 143 guests