CESSNA 172 FSX SIMULADOR (SOLUCIONADO)

Hola Comunidad Arduino

Para mi es totalmente nueva la programación en Arduino. Es un mundo Muy interesante, luego de ver innumerables videos me anime a la construcción de un simulador de vuelo Cessna 172.

Les aclaro los conocimientos en programación en Arduino Malos, en electrónica Más o Menos lo único que me sobra es ganas de terminar mi primer proyecto.

Equipos y programas

Arduino MEGA 2650 Programa para el manejo del simulador LINK2fs simulador FSX

Ayuda 1

Me ayudan a completar este Código

Tengo un switch en Pin 36 que se llama NAV/GPS

Un LED en el Pin 44 que se llama NAV

Un LED en el Pin 46 que se llama GPS

Por defecto cuando enciendes el simulador siempre esta prendido el LED en Modo NAV y cuando Pulsas el Suiche apaga el NAV y enciende el GPS y viceversa.

int estado = 0;
void setup() {  
  pinMode(36, INPUT);            // declaramos la entrada BOTON DE SELECCION DE (NAV / GPS)
  pinMode(44, OUTPUT);           // declaramos la SALIDA  LED DE (NAV)
  pinMode(46, OUTPUT);           // declaramos la SALIDA  LED DE (GPS)
}
void loop() {
  estado = digitalRead(36);       // lee el estado del boton
    if(estado == HIGH) {           // SI EL ESTADO ES ALTO
  digitalWrite(44, LOW);        // encendemos el led NAV
  digitalWrite(46, HIGH);       // encendemos el led GPS
     }
 else {                           // apagamos el led
  digitalWrite(44, HIGH);
  digitalWrite(46,LOW);
  }
}

Y este código tengo que insertarlo en otro código para que funcione completo. Ahora lo que no sé si se pueda colocar un Pin con dos funciones diferente que se ejecuten al mismo tiempo.

Ahora bien este es el Código que estoy utilizando en la actualidad donde tengo casi todos los switch del simulador funcionado con algunos errores pero funciona.
Me faltaría incluir el código de los LED de NAV y GPS.

Les agradezco cualquier ayuda

JESUS SANCHEZ

jesuscasamaturin@gmail.com

SEGUNDO CODIGO Me faltaría incluir el código de los LED de NAV y GPS.

/* 
    This code is in the public domain
    For use with "Link2fs_Multi_beta5d" or later"
    Jimspage.co.nz
    My thanks to the Guys that gave me snippets of code. 
    
    This is just a "demo" of switching the sim's lights on and off.
    Also there is a loop to indicate, via some LED's, if the individual lights are on or off.
    These all use simconnect.(not "keys")
    Some planes are not set up for individual switchings so just fiddle and 
    watch the extraction '<f' while clicking with your mouse ,,  most are OK tho.
    On some planes it is even upside-down on some switchs.
    It must have been a Monday morning job at M$ !!!
    The 10 '1's or '0's being sent equate to,,,, (in order, left to right) ,,,
    Nav, Beacon, Landing, Taxi, Strobe, Panel, Recognition, Wing, Logo, Cabin.
    
    These codes suit the use of TOGGLE switchs as are in the planes for this purpose.
    
    >>>>>>>> Make sure you have '<f' ticked in my program if you want the indications. <<<<<<<<<
    "Keys" starts from pin 32 upwards. (Mega)
*/


int CodeIn;// used on all serial reads
int KpinNo; 
int Koutpin;

String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate;

void setup() 
{
  Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
  
   for (int KoutPin = 22; KoutPin < 70; KoutPin++)// Get these pins ready as inputs  
  {
    pinMode(KoutPin, INPUT);
    digitalWrite(KoutPin, HIGH);  
  }
  for (int KoutPin = 2; KoutPin < 21; KoutPin++)// Get these pins ready as outputs  
  {
    pinMode(KoutPin, OUTPUT);
    digitalWrite(KoutPin, LOW);  
  }
  
 Serial.begin(115200);   
}

void loop() {
  {KEYS();} //Check the "keys" section
  if (Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '=') {EQUALS();} // The first identifier is "="
    if (CodeIn == '<') {LESSTHAN();}// The first identifier is "<"
    if (CodeIn == '?') {QUESTION();}// The first identifier is "?"
    if (CodeIn == '/') {SLASH();}// The first identifier is "/" (Annunciators)
  }

}

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

void EQUALS(){      // The first identifier was "="
 CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
    
         //etc etc etc
     }
}

void LESSTHAN(){    // The first identifier was "<"
CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'f':
    for (int pinNo = 2; pinNo < 12; pinNo++){//The 10 LED's to indicate lights status
    int lights = getChar();
      if (lights =='1'){digitalWrite(pinNo, HIGH);}else{digitalWrite(pinNo, LOW);} 
    }
      break;   
     }
}

void QUESTION(){    // The first identifier was "?"
CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
       
         //etc etc etc
     }
}
void SLASH(){    // The first identifier was "/" (Annunciator)
  //Do something
}
void KEYS() 
{
  Kstringnewstate = "";
  for (int KpinNo = 22; KpinNo < 70; KpinNo++){
    KpinStateSTR = String(digitalRead(KpinNo)); 
    KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 22));
    if (KpinStateSTR != KoldpinStateSTR)
    {
      if (KpinNo == 31){if (KpinStateSTR == "1" ){Serial.println ("C461");}else {Serial.println ("C460");}}//Panel lights
      if (KpinNo == 33){if (KpinStateSTR == "1" ){Serial.println ("C65030");}else {Serial.println ("C65030");}}//FLAPS 0%
      if (KpinNo == 35){if (KpinStateSTR == "1" ){Serial.println ("C65000");}else {Serial.println ("C65000");}}//FLAPS 10% 
      if (KpinNo == 37){if (KpinStateSTR == "1" ){Serial.println ("C65075");}else {Serial.println ("C65075");}}//FLAPS 075%
      if (KpinNo == 39){if (KpinStateSTR == "1" ){Serial.println ("C65100");}else {Serial.println ("C65100");}}//FLAPS 0100%
      if (KpinNo == 41){if (KpinStateSTR == "1" ){Serial.println ("A431");}else {Serial.println ("A430");}}//AVIONICA MASTER lights
      if (KpinNo == 43){if (KpinStateSTR == "1" ){Serial.println ("C05");}else {Serial.println ("C06");}}//PITOP HEAT
      if (KpinNo == 45){if (KpinStateSTR == "1" ){Serial.println ("C451");}else {Serial.println ("C450");}}//Strobe lights
      if (KpinNo == 47){if (KpinStateSTR == "1" ){Serial.println ("C411");}else {Serial.println ("C410");}}//Nav lights
      if (KpinNo == 49){if (KpinStateSTR == "1" ){Serial.println ("C441");}else {Serial.println ("C440");}}//Taxi lights
      if (KpinNo == 51){if (KpinStateSTR == "1" ){Serial.println ("C431");}else {Serial.println ("C430");}}//Landing lights
      if (KpinNo == 53){if (KpinStateSTR == "1" ){Serial.println ("C421");}else {Serial.println ("C420");}}//Beacon lights 
      if (KpinNo == 26){if (KpinStateSTR == "1" ){Serial.println ("F01");}else {Serial.println ("F01");}}//FUELS PUMPS
      if (KpinNo == 28){if (KpinStateSTR == "1" ){Serial.println ("E16");}else {Serial.println ("E16");}}//MASTER bateria
      if (KpinNo == 30){if (KpinStateSTR == "1" ){Serial.println ("E25");}else {Serial.println ("E25");}}//MASTER ALTERNADOR
      if (KpinNo == 32){if (KpinStateSTR == "1" ){Serial.println ("E35");}else {Serial.println ("E35");}}//ENSENDIDO
      if (KpinNo == 34){if (KpinStateSTR == "1" ){Serial.println ("");}else {Serial.println ("");}}//ALT ATATIC AIR
      if (KpinNo == 36){if (KpinStateSTR == "1" ){Serial.println ("A54");}else {Serial.println ("A540");}}//NAV O GPS
      
      if (KpinNo == 40){if (KpinStateSTR == "1" ){Serial.println ("");}else {Serial.println ("");}}//AOGADOR OFF
      if (KpinNo == 38){if (KpinStateSTR == "1" ){Serial.println ("F041");}else {Serial.println ("F041");}}//GASOLINA CENTRO
      if (KpinNo == 22){if (KpinStateSTR == "1" ){Serial.println ("F042");}else {Serial.println ("F042");}}//GASOLINA IZQUIERDO
      if (KpinNo == 24){if (KpinStateSTR == "1" ){Serial.println ("F043");}else {Serial.println ("F043");}}//GASOLINA DERECHO
      if (KpinNo == 42){if (KpinStateSTR == "1" ){Serial.println ("C041");}else {Serial.println ("C040");}}// PARKING BRAKE
         
      
      
      //now the "keys" bit. Note the pinNo 22 in the line above and the line below.
      if (KpinNo > 22){
      Serial.print ("D"); 
      if (KpinNo < 10) Serial.print ("0");
      Serial.print (KpinNo);
      Serial.println (KpinStateSTR);
      }
    }
    Kstringnewstate += KpinStateSTR;
  }
  Kstringoldstate = Kstringnewstate;
}

A ver si esto funciona
nunca uses un pulsador leyendo si esta en 1 o 0, al menos agrega otra variable como estadoAnt para ver la transisicion porque si tienes rebotes te disparará varias veces.

/* 
    This code is in the public domain
    For use with "Link2fs_Multi_beta5d" or later"
    Jimspage.co.nz
    My thanks to the Guys that gave me snippets of code. 
    
    This is just a "demo" of switching the sim's lights on and off.
    Also there is a loop to indicate, via some LED's, if the individual lights are on or off.
    These all use simconnect.(not "keys")
    Some planes are not set up for individual switchings so just fiddle and 
    watch the extraction '<f' while clicking with your mouse ,,  most are OK tho.
    On some planes it is even upside-down on some switchs.
    It must have been a Monday morning job at M$ !!!
    The 10 '1's or '0's being sent equate to,,,, (in order, left to right) ,,,
    Nav, Beacon, Landing, Taxi, Strobe, Panel, Recognition, Wing, Logo, Cabin.
    
    These codes suit the use of TOGGLE switchs as are in the planes for this purpose.
    
    >>>>>>>> Make sure you have '<f' ticked in my program if you want the indications. <<<<<<<<<
    "Keys" starts from pin 32 upwards. (Mega)
*/

const byte PinNAVGPS	36
const byte PinNAV 		44
const byte PinGPS 		46

int CodeIn;// used on all serial reads
int KpinNo; 
int Koutpin;
int estado 				= 0;
int estadoAnt 			= 0;

String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate;

void setup() 
{
  Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
  
  for (int KoutPin = 22; KoutPin < 70; KoutPin++) {	// Get these pins ready as inputs  
    pinMode(KoutPin, INPUT);
    digitalWrite(KoutPin, HIGH);  
  }

  for (int KoutPin = 2; KoutPin < 21; KoutPin++)  {	// Get these pins ready as outputs  
    pinMode(KoutPin, OUTPUT);
    digitalWrite(KoutPin, LOW);  
  }
  
  Serial.begin(115200);   
  pinMode(PinNAVGPS, INPUT);            			// declaramos la entrada BOTON DE SELECCION DE (NAV / GPS)
  pinMode(PinNAV, OUTPUT);           				// declaramos la SALIDA  LED DE (NAV)
  pinMode(PinGPS, OUTPUT);           				// declaramos la SALIDA  LED DE (GPS)

}

void loop() {

  estado = digitalRead(PinNAVGPS);       			// lee el estado del boton
  if (estado == HIGH && estadoAnt == LOW) {          					// SI EL ESTADO ES ALTO
  		digitalWrite(PinNAV, LOW);        			// encendemos el led NAV
  		digitalWrite(PinGPS, HIGH);       			// encendemos el led GPS
  } else {                           				// apagamos el led
  		digitalWrite(PinNAV, HIGH);
  		digitalWrite(PinGPS,LOW);
  }
  estadoAnt = estado;

  KEYS(); 											//Check the "keys" section
  
  if (Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '=') {
    	EQUALS();
    } // The first identifier is "="
    if (CodeIn == '<') {
    	LESSTHAN();
    }// The first identifier is "<"
    if (CodeIn == '?') {
    	QUESTION();
    }// The first identifier is "?"
    if (CodeIn == '/') {
    	SLASH();
    }// The first identifier is "/" (Annunciators)
  }

}

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

void EQUALS(){      // The first identifier was "="
 CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
    
         //etc etc etc
     }
}

void LESSTHAN(){    // The first identifier was "<"
CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'f':
    for (int pinNo = 2; pinNo < 12; pinNo++){//The 10 LED's to indicate lights status
    int lights = getChar();
      if (lights =='1'){digitalWrite(pinNo, HIGH);}else{digitalWrite(pinNo, LOW);} 
    }
      break;   
     }
}

void QUESTION(){    // The first identifier was "?"
CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
       
         //etc etc etc
     }
}
void SLASH(){    // The first identifier was "/" (Annunciator)
  //Do something
}
void KEYS() 
{
  Kstringnewstate = "";
  for (int KpinNo = 22; KpinNo < 70; KpinNo++){
    KpinStateSTR = String(digitalRead(KpinNo)); 
    KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 22));
    if (KpinStateSTR != KoldpinStateSTR)
    {
      if (KpinNo == 31){if (KpinStateSTR == "1" ){Serial.println ("CPinGPS1");}else {Serial.println ("CPinGPS0");}}//Panel lights
      if (KpinNo == 33){if (KpinStateSTR == "1" ){Serial.println ("C65030");}else {Serial.println ("C65030");}}//FLAPS 0%
      if (KpinNo == 35){if (KpinStateSTR == "1" ){Serial.println ("C65000");}else {Serial.println ("C65000");}}//FLAPS 10% 
      if (KpinNo == 37){if (KpinStateSTR == "1" ){Serial.println ("C65075");}else {Serial.println ("C65075");}}//FLAPS 075%
      if (KpinNo == 39){if (KpinStateSTR == "1" ){Serial.println ("C65100");}else {Serial.println ("C65100");}}//FLAPS 0100%
      if (KpinNo == 41){if (KpinStateSTR == "1" ){Serial.println ("A431");}else {Serial.println ("A430");}}//AVIONICA MASTER lights
      if (KpinNo == 43){if (KpinStateSTR == "1" ){Serial.println ("C05");}else {Serial.println ("C06");}}//PITOP HEAT
      if (KpinNo == 45){if (KpinStateSTR == "1" ){Serial.println ("C451");}else {Serial.println ("C450");}}//Strobe lights
      if (KpinNo == 47){if (KpinStateSTR == "1" ){Serial.println ("C411");}else {Serial.println ("C410");}}//Nav lights
      if (KpinNo == 49){if (KpinStateSTR == "1" ){Serial.println ("CPinNAV1");}else {Serial.println ("CPinNAV0");}}//Taxi lights
      if (KpinNo == 51){if (KpinStateSTR == "1" ){Serial.println ("C431");}else {Serial.println ("C430");}}//Landing lights
      if (KpinNo == 53){if (KpinStateSTR == "1" ){Serial.println ("C421");}else {Serial.println ("C420");}}//Beacon lights 
      if (KpinNo == 26){if (KpinStateSTR == "1" ){Serial.println ("F01");}else {Serial.println ("F01");}}//FUELS PUMPS
      if (KpinNo == 28){if (KpinStateSTR == "1" ){Serial.println ("E16");}else {Serial.println ("E16");}}//MASTER bateria
      if (KpinNo == 30){if (KpinStateSTR == "1" ){Serial.println ("E25");}else {Serial.println ("E25");}}//MASTER ALTERNADOR
      if (KpinNo == 32){if (KpinStateSTR == "1" ){Serial.println ("E35");}else {Serial.println ("E35");}}//ENSENDIDO
      if (KpinNo == 34){if (KpinStateSTR == "1" ){Serial.println ("");}else {Serial.println ("");}}//ALT ATATIC AIR
      if (KpinNo == PinNAVGPS){if (KpinStateSTR == "1" ){Serial.println ("A54");}else {Serial.println ("A540");}}//NAV O GPS
      
      if (KpinNo == 40){if (KpinStateSTR == "1" ){Serial.println ("");}else {Serial.println ("");}}//AOGADOR OFF
      if (KpinNo == 38){if (KpinStateSTR == "1" ){Serial.println ("F041");}else {Serial.println ("F041");}}//GASOLINA CENTRO
      if (KpinNo == 22){if (KpinStateSTR == "1" ){Serial.println ("F042");}else {Serial.println ("F042");}}//GASOLINA IZQUIERDO
      if (KpinNo == 24){if (KpinStateSTR == "1" ){Serial.println ("F043");}else {Serial.println ("F043");}}//GASOLINA DERECHO
      if (KpinNo == 42){if (KpinStateSTR == "1" ){Serial.println ("C041");}else {Serial.println ("C040");}}// PARKING BRAKE
         
      
      
      //now the "keys" bit. Note the pinNo 22 in the line above and the line below.
      if (KpinNo > 22){
      Serial.print ("D"); 
      if (KpinNo < 10) Serial.print ("0");
      Serial.print (KpinNo);
      Serial.println (KpinStateSTR);
      }
    }
    Kstringnewstate += KpinStateSTR;
  }
  Kstringoldstate = Kstringnewstate;
}

GRACIAS POR AYUDAR pero me da un error

FINAL_DE_UN_AMIGO:23: error: expected initializer before numeric constant
FINAL_DE_UN_AMIGO.ino: In function 'void setup()':
FINAL_DE_UN_AMIGO:50: error: 'PinNAVGPS' was not declared in this scope
FINAL_DE_UN_AMIGO:51: error: 'PinNAV' was not declared in this scope
FINAL_DE_UN_AMIGO:52: error: 'PinGPS' was not declared in this scope
FINAL_DE_UN_AMIGO.ino: In function 'void loop()':
FINAL_DE_UN_AMIGO:58: error: 'PinNAVGPS' was not declared in this scope
FINAL_DE_UN_AMIGO:60: error: 'PinNAV' was not declared in this scope
FINAL_DE_UN_AMIGO:61: error: 'PinGPS' was not declared in this scope
FINAL_DE_UN_AMIGO:63: error: 'PinNAV' was not declared in this scope
FINAL_DE_UN_AMIGO:64: error: 'PinGPS' was not declared in this scope
FINAL_DE_UN_AMIGO:71: error: 'CodeIn' was not declared in this scope
FINAL_DE_UN_AMIGO.ino: In function 'void EQUALS()':
FINAL_DE_UN_AMIGO:95: error: 'CodeIn' was not declared in this scope
FINAL_DE_UN_AMIGO.ino: In function 'void LESSTHAN()':
FINAL_DE_UN_AMIGO:114: error: 'CodeIn' was not declared in this scope
FINAL_DE_UN_AMIGO.ino: In function 'void QUESTION()':
FINAL_DE_UN_AMIGO:134: error: 'CodeIn' was not declared in this scope
FINAL_DE_UN_AMIGO.ino: In function 'void KEYS()':
FINAL_DE_UN_AMIGO:179: error: 'PinNAVGPS' was not declared in this scope
expected initializer before numeric constant

Sorry, no se en que pensaba

const byte PinNAVGPS	= 36;
const byte PinNAV 		= 44;
const byte PinGPS 		= 46;

cambia esto arriba en las definiciones

GRACIAS surbyte pero no funciona sigue igual enciende el Nav y cuando presionas el botón Nav/gps parpadea el Gps y cuando lo sueltas vuelve a Nav

gracias de nuevo por tu tiempo

en el código anterior

Secuencia

Prendes el simulador

Por defecto el sistema de Navegacion se coloca en NAV (el led NAV esta encendido)

ok cuando deseas cambiar el sisntema de Navegacion de NAV a GPS solo Presionas Una ves el Botón de NAV/GPS y se apaga el LED NAV y enciende el LED GPS

si te fijas en la linea 179 esta el comando de cambio de sistema de Navegacion

Que tal ahora?

/* 
    This code is in the public domain
    For use with "Link2fs_Multi_beta5d" or later"
    Jimspage.co.nz
    My thanks to the Guys that gave me snippets of code. 
    
    This is just a "demo" of switching the sim's lights on and off.
    Also there is a loop to indicate, via some LED's, if the individual lights are on or off.
    These all use simconnect.(not "keys")
    Some planes are not set up for individual switchings so just fiddle and 
    watch the extraction '<f' while clicking with your mouse ,,  most are OK tho.
    On some planes it is even upside-down on some switchs.
    It must have been a Monday morning job at M$ !!!
    The 10 '1's or '0's being sent equate to,,,, (in order, left to right) ,,,
    Nav, Beacon, Landing, Taxi, Strobe, Panel, Recognition, Wing, Logo, Cabin.
    
    These codes suit the use of TOGGLE switchs as are in the planes for this purpose.
    
    >>>>>>>> Make sure you have '<f' ticked in my program if you want the indications. <<<<<<<<<
    "Keys" starts from pin 32 upwards. (Mega)
*/

const byte PinNAVGPS	= 36;
const byte PinNAV 		= 44;
const byte PinGPS 		= 46;

int CodeIn;// used on all serial reads
int KpinNo; 
int Koutpin;
int estado 				   = 0;
int estadoAnt 			 = 0;
bool StatusNAVGPS = false;

String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate;

void setup() 
{
  Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
  
  for (int KoutPin = 22; KoutPin < 70; KoutPin++) {	// Get these pins ready as inputs  
    pinMode(KoutPin, INPUT);
    digitalWrite(KoutPin, HIGH);  
  }

  for (int KoutPin = 2; KoutPin < 21; KoutPin++)  {	// Get these pins ready as outputs  
    pinMode(KoutPin, OUTPUT);
    digitalWrite(KoutPin, LOW);  
  }
  
  Serial.begin(115200);   
  pinMode(PinNAVGPS, INPUT);            			// declaramos la entrada BOTON DE SELECCION DE (NAV / GPS)
  pinMode(PinNAV, OUTPUT);           				// declaramos la SALIDA  LED DE (NAV)
  pinMode(PinGPS, OUTPUT);           				// declaramos la SALIDA  LED DE (GPS)

}

void loop() {

  estado = digitalRead(PinNAVGPS);       			// lee el estado del boton
  if (estado == HIGH && estadoAnt == LOW) {  
      StatusNAVGPS = !StatusNAVGPS;
  }
          					// SI EL ESTADO ES ALTO
  if (StatusNAVGPS)
  		digitalWrite(PinNAV, LOW);        			// encendemos el led NAV
  		digitalWrite(PinGPS, HIGH);       			// encendemos el led GPS
  } else {                           				// apagamos el led
  		digitalWrite(PinNAV, HIGH);
  		digitalWrite(PinGPS,LOW);
  }
  estadoAnt = estado;

  KEYS(); 											//Check the "keys" section
  
  if (Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '=') {
    	EQUALS();
    } // The first identifier is "="
    if (CodeIn == '<') {
    	LESSTHAN();
    }// The first identifier is "<"
    if (CodeIn == '?') {
    	QUESTION();
    }// The first identifier is "?"
    if (CodeIn == '/') {
    	SLASH();
    }// The first identifier is "/" (Annunciators)
  }

}

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

void EQUALS(){      // The first identifier was "="
 CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
    
         //etc etc etc
     }
}

void LESSTHAN(){    // The first identifier was "<"
CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'f':
    for (int pinNo = 2; pinNo < 12; pinNo++){//The 10 LED's to indicate lights status
    int lights = getChar();
      if (lights =='1'){digitalWrite(pinNo, HIGH);}else{digitalWrite(pinNo, LOW);} 
    }
      break;   
     }
}

void QUESTION(){    // The first identifier was "?"
CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
       
         //etc etc etc
     }
}
void SLASH(){    // The first identifier was "/" (Annunciator)
  //Do something
}
void KEYS() 
{
  Kstringnewstate = "";
  for (int KpinNo = 22; KpinNo < 70; KpinNo++){
    KpinStateSTR = String(digitalRead(KpinNo)); 
    KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 22));
    if (KpinStateSTR != KoldpinStateSTR)
    {
      if (KpinNo == 31){if (KpinStateSTR == "1" ){Serial.println ("CPinGPS1");}else {Serial.println ("CPinGPS0");}}//Panel lights
      if (KpinNo == 33){if (KpinStateSTR == "1" ){Serial.println ("C65030");}else {Serial.println ("C65030");}}//FLAPS 0%
      if (KpinNo == 35){if (KpinStateSTR == "1" ){Serial.println ("C65000");}else {Serial.println ("C65000");}}//FLAPS 10% 
      if (KpinNo == 37){if (KpinStateSTR == "1" ){Serial.println ("C65075");}else {Serial.println ("C65075");}}//FLAPS 075%
      if (KpinNo == 39){if (KpinStateSTR == "1" ){Serial.println ("C65100");}else {Serial.println ("C65100");}}//FLAPS 0100%
      if (KpinNo == 41){if (KpinStateSTR == "1" ){Serial.println ("A431");}else {Serial.println ("A430");}}//AVIONICA MASTER lights
      if (KpinNo == 43){if (KpinStateSTR == "1" ){Serial.println ("C05");}else {Serial.println ("C06");}}//PITOP HEAT
      if (KpinNo == 45){if (KpinStateSTR == "1" ){Serial.println ("C451");}else {Serial.println ("C450");}}//Strobe lights
      if (KpinNo == 47){if (KpinStateSTR == "1" ){Serial.println ("C411");}else {Serial.println ("C410");}}//Nav lights
      if (KpinNo == 49){if (KpinStateSTR == "1" ){Serial.println ("CPinNAV1");}else {Serial.println ("CPinNAV0");}}//Taxi lights
      if (KpinNo == 51){if (KpinStateSTR == "1" ){Serial.println ("C431");}else {Serial.println ("C430");}}//Landing lights
      if (KpinNo == 53){if (KpinStateSTR == "1" ){Serial.println ("C421");}else {Serial.println ("C420");}}//Beacon lights 
      if (KpinNo == 26){if (KpinStateSTR == "1" ){Serial.println ("F01");}else {Serial.println ("F01");}}//FUELS PUMPS
      if (KpinNo == 28){if (KpinStateSTR == "1" ){Serial.println ("E16");}else {Serial.println ("E16");}}//MASTER bateria
      if (KpinNo == 30){if (KpinStateSTR == "1" ){Serial.println ("E25");}else {Serial.println ("E25");}}//MASTER ALTERNADOR
      if (KpinNo == 32){if (KpinStateSTR == "1" ){Serial.println ("E35");}else {Serial.println ("E35");}}//ENSENDIDO
      if (KpinNo == 34){if (KpinStateSTR == "1" ){Serial.println ("");}else {Serial.println ("");}}//ALT ATATIC AIR
      if (KpinNo == PinNAVGPS){if (KpinStateSTR == "1" ){Serial.println ("A54");}else {Serial.println ("A540");}}//NAV O GPS
      
      if (KpinNo == 40){if (KpinStateSTR == "1" ){Serial.println ("");}else {Serial.println ("");}}//AOGADOR OFF
      if (KpinNo == 38){if (KpinStateSTR == "1" ){Serial.println ("F041");}else {Serial.println ("F041");}}//GASOLINA CENTRO
      if (KpinNo == 22){if (KpinStateSTR == "1" ){Serial.println ("F042");}else {Serial.println ("F042");}}//GASOLINA IZQUIERDO
      if (KpinNo == 24){if (KpinStateSTR == "1" ){Serial.println ("F043");}else {Serial.println ("F043");}}//GASOLINA DERECHO
      if (KpinNo == 42){if (KpinStateSTR == "1" ){Serial.println ("C041");}else {Serial.println ("C040");}}// PARKING BRAKE
         
      
      
      //now the "keys" bit. Note the pinNo 22 in the line above and the line below.
      if (KpinNo > 22){
      Serial.print ("D"); 
      if (KpinNo < 10) Serial.print ("0");
      Serial.print (KpinNo);
      Serial.println (KpinStateSTR);
      }
    }
    Kstringnewstate += KpinStateSTR;
  }
  Kstringoldstate = Kstringnewstate;
}

CODIGO_AMIGO_SURBYTE:67: error: expected unqualified-id before 'else'
CODIGO_AMIGO_SURBYTE:71: error: 'estadoAnt' does not name a type
CODIGO_AMIGO_SURBYTE:73: error: expected constructor, destructor, or type conversion before ';' token
CODIGO_AMIGO_SURBYTE:75: error: expected unqualified-id before 'if'
expected unqualified-id before 'else'

GRACIAS de nuevo amigo y disculpa

Muchísimas gracias al amigo SURBYTE por haberle dedicado su valioso tiempo a la ayuda de mi problema no me canso de darte las gracias Amigo.

Aquí les dejo el código SOLUCIONADO por si alguien lo necesita

/* 
    This code is in the public domain
    For use with "Link2fs_Multi_beta5d" or later"
    Jimspage.co.nz
    My thanks to the Guys that gave me snippets of code. 
    
    This is just a "demo" of switching the sim's lights on and off.
    Also there is a loop to indicate, via some LED's, if the individual lights are on or off.
    These all use simconnect.(not "keys")
    Some planes are not set up for individual switchings so just fiddle and 
    watch the extraction '<f' while clicking with your mouse ,,  most are OK tho.
    On some planes it is even upside-down on some switchs.
    It must have been a Monday morning job at M$ !!!
    The 10 '1's or '0's being sent equate to,,,, (in order, left to right) ,,,
    Nav, Beacon, Landing, Taxi, Strobe, Panel, Recognition, Wing, Logo, Cabin.
    
    These codes suit the use of TOGGLE switchs as are in the planes for this purpose.
    
    >>>>>>>> Make sure you have '<f' ticked in my program if you want the indications. <<<<<<<<<
    "Keys" starts from pin 32 upwards. (Mega)
*/

const byte PinNAVGPS	= 36;
const byte PinNAV 		= 44;
const byte PinGPS 		= 46;

int CodeIn;// used on all serial reads
int KpinNo; 
int Koutpin;
int estado 				   = 0;
int estadoAnt 			 = 0;
bool StatusNAVGPS = false;

String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate;

void setup() 
{
  Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
  
  for (int KoutPin = 22; KoutPin < 70; KoutPin++) {	// Get these pins ready as inputs  
    pinMode(KoutPin, INPUT);
    digitalWrite(KoutPin, HIGH);  
  }

  for (int KoutPin = 2; KoutPin < 21; KoutPin++)  {	// Get these pins ready as outputs  
    pinMode(KoutPin, OUTPUT);
    digitalWrite(KoutPin, LOW);  
  }
  
  Serial.begin(115200);   
  pinMode(PinNAVGPS, INPUT);            			// declaramos la entrada BOTON DE SELECCION DE (NAV / GPS)
  pinMode(PinNAV, OUTPUT);           				// declaramos la SALIDA  LED DE (NAV)
  pinMode(PinGPS, OUTPUT);           				// declaramos la SALIDA  LED DE (GPS)

}

void loop() {

  estado = digitalRead(PinNAVGPS);       			// lee el estado del boton
  if (estado == HIGH && estadoAnt == LOW) {  
      StatusNAVGPS = !StatusNAVGPS;
  }
          					// SI EL ESTADO ES ALTO
  if (StatusNAVGPS){
  		digitalWrite(PinNAV, LOW);        			// encendemos el led NAV
  		digitalWrite(PinGPS, HIGH);       			// encendemos el led GPS
  } 
  else {                           				// apagamos el led
  		digitalWrite(PinNAV, HIGH);
  		digitalWrite(PinGPS,LOW);
  }
  estadoAnt = estado;

  KEYS(); 											//Check the "keys" section
  
  if (Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '=') {
    	EQUALS();
    } // The first identifier is "="
    if (CodeIn == '<') {
    	LESSTHAN();
    }// The first identifier is "<"
    if (CodeIn == '?') {
    	QUESTION();
    }// The first identifier is "?"
    if (CodeIn == '/') {
    	SLASH();
    }// The first identifier is "/" (Annunciators)
  }

}

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

void EQUALS(){      // The first identifier was "="
 CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
    
         //etc etc etc
     }
}

void LESSTHAN(){    // The first identifier was "<"
CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'f':
    for (int pinNo = 2; pinNo < 12; pinNo++){//The 10 LED's to indicate lights status
    int lights = getChar();
      if (lights =='1'){digitalWrite(pinNo, HIGH);}else{digitalWrite(pinNo, LOW);} 
    }
      break;   
     }
}

void QUESTION(){    // The first identifier was "?"
CodeIn = getChar(); // Get another character
  switch(CodeIn) {// Now lets find what to do with it
    case 'A'://Found the second identifier
       //Do something
    break;
     
    case 'B':
       //Do something
    break;
     
    case 'C':
       //Do something
    break;
       
         //etc etc etc
     }
}
void SLASH(){    // The first identifier was "/" (Annunciator)
  //Do something
}
void KEYS() {
  
  Kstringnewstate = "";
  for (int KpinNo = 22; KpinNo < 70; KpinNo++){
    KpinStateSTR = String(digitalRead(KpinNo)); 
    KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 22));
    if (KpinStateSTR != KoldpinStateSTR)    {
      if (KpinNo == 31){if (KpinStateSTR == "1" ){Serial.println ("CPinGPS1");}else {Serial.println ("CPinGPS0");}}//Panel lights
      if (KpinNo == 33){if (KpinStateSTR == "1" ){Serial.println ("C65030");}}//FLAPS 0%
      if (KpinNo == 35){if (KpinStateSTR == "1" ){Serial.println ("C65000");}}//FLAPS 10% 
      if (KpinNo == 37){if (KpinStateSTR == "1" ){Serial.println ("C65075");}}//FLAPS 075%
      if (KpinNo == 39){if (KpinStateSTR == "1" ){Serial.println ("C65100");}}//FLAPS 0100%
      if (KpinNo == 41){if (KpinStateSTR == "1" ){Serial.println ("A431");}else {Serial.println ("A430");}}//AVIONICA MASTER lights
      if (KpinNo == 43){if (KpinStateSTR == "1" ){Serial.println ("C05");}else {Serial.println ("C06");}}//PITOP HEAT
      if (KpinNo == 45){if (KpinStateSTR == "1" ){Serial.println ("C451");}else {Serial.println ("C450");}}//Strobe lights
      if (KpinNo == 47){if (KpinStateSTR == "1" ){Serial.println ("C411");}else {Serial.println ("C410");}}//Nav lights
      if (KpinNo == 49){if (KpinStateSTR == "1" ){Serial.println ("C441");}else {Serial.println ("C440");}}//Taxi lights
      if (KpinNo == 51){if (KpinStateSTR == "1" ){Serial.println ("C431");}else {Serial.println ("C430");}}//Landing lights
      if (KpinNo == 53){if (KpinStateSTR == "1" ){Serial.println ("C421");}else {Serial.println ("C420");}}//Beacon lights 
      if (KpinNo == 26){if (KpinStateSTR == "1" ){Serial.println ("F01");}}//FUELS PUMPS
      if (KpinNo == 28){if (KpinStateSTR == "1" ){Serial.println ("E16");}}//MASTER bateria
      if (KpinNo == 30){if (KpinStateSTR == "1" ){Serial.println ("E25");}}//MASTER ALTERNADOR
      if (KpinNo == 32){if (KpinStateSTR == "1" ){Serial.println ("E35");}}//ENCENDIDO
      if (KpinNo == 34){if (KpinStateSTR == "1" ){Serial.println ("");}else {Serial.println ("");}}//ALT ATATIC AIR
      if (KpinNo == PinNAVGPS){if (KpinStateSTR == "1" ){Serial.println ("A54");}else {Serial.println ("A540");}}//NAV O GPS
      
      if (KpinNo == 40){if (KpinStateSTR == "1" ){Serial.println ("");}else {Serial.println ("");}}//AOGADOR OFF
      if (KpinNo == 38){if (KpinStateSTR == "1" ){Serial.println ("F041");}}//GASOLINA CENTRO
      if (KpinNo == 22){if (KpinStateSTR == "1" ){Serial.println ("F042");}}//GASOLINA IZQUIERDO
      
      if (KpinNo == 24){
          if (KpinStateSTR == "1" ){
              Serial.println ("F043");}
          //else {
          //    Serial.println ("F043");
          //}
       }//GASOLINA DERECHO
      
      if (KpinNo == 42){if (KpinStateSTR == "1" ){Serial.println ("C041");}else {Serial.println ("C040");}}// PARKING BRAKE
         
      
      
      //now the "keys" bit. Note the pinNo 22 in the line above and the line below.
      if (KpinNo > 22){
      Serial.print ("D"); 
      if (KpinNo < 10) Serial.print ("0");
      Serial.print (KpinNo);
      Serial.println (KpinStateSTR);
      }
    }
    Kstringnewstate += KpinStateSTR;
  }
  Kstringoldstate = Kstringnewstate;
 }

Disculpen que me enganche tan tarde de un hilo ya resuelto, pero quiero comentarles mi experiencia con el cockpit de un Baron 58.

Jamás usé el Link2Fs por ser muy caro y no ser tan necesario, eso lo solucioné usando dos placas: una leonardo (usada como joysitick mediante LeoJoy) y otra Mega 2560 para controles, ambas conectadas a través de los puertos TX/RX <--> RX/TX cominicándose entre ellos todas "las novedades".

De una manera similar a como trabajan los paneles y demases de Saytek. Cabe aclarar que fue un terrible incordio la programación de ese sistema, pero con ayuda de amigos que saben un poco más, todo fue posible.

Como el sistema ve a la Leonardo como un Joysitick no necesita de ningún programa aparte ni de linkeado por soft.

Abrazos y disculpen que me haya metido tan tarde.

Héctor