Hi OAM..I'll give you bit of a head start..or a taste of what you are getting yourself into.
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;
}
}