Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    Jan 2016
    Location
    France
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Question Instruction From CARD

    Hi everyone,

    I have trouble with my program. On Link2fs the instruction D320-D330-D331 are sent without stopping.
    I don't know what D331 or the other one..., are refer to.

    Do you have any idea ?

    Thanks for answering
    Vincent

  2. #2
    150+ Forum Groupie BuzziBi's Avatar
    Join Date
    Mar 2013
    Location
    Norway
    Posts
    275
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Instruction From CARD

    This comes from this part of the code:
    if (KpinNo != 13){
    Serial.print ("D");
    if (KpinNo < 10) Serial.print ("0");
    Serial.print (KpinNo);
    Serial.println (KpinStateSTR);

    In your case the pin 31, 32 and 33 is informing that it is eigther 1 or 0
    Pin - nr - (1 or 0) (if a switch is used on/off )
    D - 33 - 1

    Check what is connected to this pins, if other than switches, edit this lines:
    for (int KoutPin = 2; KoutPin < 70; KoutPin++)// Get all the pins ready for "Keys"
    and
    for (int KpinNo = 2; KpinNo < 70; KpinNo++){
    KpinStateSTR = String(digitalRead(KpinNo));
    KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 2));
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  3. #3
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    Jan 2016
    Location
    France
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Instruction From CARD

    Here is my code (merge of code that I found on internet, thanks to the writer ...) :
    #include "math.h"
    #include "Quadrature.h"
    #include "LedControl.h"


    Quadrature quad1(8, 9);


    LedControl led_Display_1 = LedControl(32,33,34,;


    int CodeIn;// used on all serial reads
    int X;// a rotary variable
    int Xold;// the old reading
    int Xdif;// the difference since last loop
    int active; // the mode thats active
    int activeold;
    int mark; // shows where the cursor is in the likes of ADF etc
    int buttonFunction = 1; // Mode selection


    int Count; // This variable used in loops in the EQUALS() function
    int COM1[4],COM1SB[4], COM2[4], COM2SB[4], NAV1[4], NAV1SB[4], NAV2[4],NAV2SB[4], ADF[4],Xpdr[4],DME[4];


    String Digit; // Variable as a string to take from getChar()
    String oldpinStateSTR, pinStateSTR, pinStateString, APsp, APspold, stringnewstate,stringoldstate;


    void setup()
    {
    pinMode(13,OUTPUT);
    digitalWrite(13,LOW);
    for (int doutPin = 10; doutPin <= 53; doutPin++) // setup the input pins
    {
    pinMode(doutPin, INPUT);
    digitalWrite(doutPin, HIGH);
    }
    for (int PinNo = 54; PinNo <= 69; PinNo++)// Get all the OUTPUT pins ready.
    {
    pinMode(PinNo, OUTPUT);
    }
    mark = 10;



    delay (500);
    led_Display_1.shutdown(0,false);
    delay (500);



    led_Display_1.setIntensity(0,4);


    led_Display_1.clearDisplay(0);


    Serial.begin(115200);

    }
    void loop()
    {
    {INPUTPINS();} //Check the "button pressed" section
    {ACTIVE();}
    {ROTARYS();} // go and check the rotary encoder
    if (Serial.available())
    {
    CodeIn = getChar();
    if (CodeIn == '=')
    {EQUALS();}
    }

    }


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




    void EQUALS(){ // The first identifier was "="
    CodeIn = getChar(); // Get another character
    switch(CodeIn) {// Now lets find what to do with it
    case 'A': //COMM1 Active
    Count = 0;
    while (Count < 4 ) // Counting fro 0 to 4. Five digits to store in the COM1 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.
    }
    COM1[Count] = Digit.toInt(); // Turn String Digit into an Integer and store it in the Array for later
    Count++; // add one to the count
    }
    if (active==14) // Because our display is used for multiple radios we only want it updating the display for the selected
    { // radio(s)
    led_Display_1.setDigit(0,0,COM1[0],false);
    led_Display_1.setDigit(0,1,COM1[1],false);
    led_Display_1.setDigit(0,2,COM1[2],true);
    led_Display_1.setDigit(0,3,COM1[3],false);

    }

    break;

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

    }

    break;


    case 'C': //COMM2 Active
    Count = 0;
    while (Count < 5 )
    {
    Digit = "";
    Digit += getChar();
    if (Digit ==".")
    {
    Digit = "";
    Digit += getChar();
    }
    COM2[Count] = Digit.toInt();
    Count++;
    }
    if (active==15)
    {
    led_Display_1.setDigit(0,0,COM2[0],false);
    led_Display_1.setDigit(0,1,COM2[1],false);
    led_Display_1.setDigit(0,2,COM2[2],true);
    led_Display_1.setDigit(0,3,COM2[3],false);
    }

    break;

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

    }

    break;

    case 'E': // Nav1 Active
    Count = 0;
    while (Count < 5 )
    {
    Digit = "";
    Digit += getChar();
    if (Digit ==".")
    {
    Digit = "";
    Digit += getChar();
    }
    NAV1[Count] = Digit.toInt();
    Count++;
    }
    if (active==16)
    {
    led_Display_1.setDigit(0,0,NAV1[0],false);
    led_Display_1.setDigit(0,1,NAV1[1],false);
    led_Display_1.setDigit(0,2,NAV1[2],true);
    led_Display_1.setDigit(0,3,NAV1[3],false);

    }

    break;

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

    }

    break;

    case 'G': // Nav2 Active
    Count = 0;
    while (Count < 5 )
    {
    Digit = "";
    Digit += getChar();
    if (Digit ==".")
    {
    Digit = "";
    Digit += getChar();
    }
    NAV2[Count] = Digit.toInt();
    Count++;
    }
    if (active==17)
    {
    led_Display_1.setDigit(0,0,NAV2[0],false);
    led_Display_1.setDigit(0,1,NAV2[1],false);
    led_Display_1.setDigit(0,2,NAV2[2],true);
    led_Display_1.setDigit(0,3,NAV2[3],false);

    }

    break;

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

    }

    break;

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

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

    }

    break;

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

    Xpdr[Count] = Digit.toInt();
    Count++;
    }
    if (active==1
    {
    led_Display_1.setDigit(3,7,Xpdr[0],false);
    led_Display_1.setDigit(3,6,Xpdr[1],false);
    led_Display_1.setDigit(3,5,Xpdr[2],false);
    led_Display_1.setDigit(3,4,Xpdr[3],false);
    }
    break;
    }
    }


    int INPUTPINS(){
    stringnewstate = "";
    for (int pinNo = 10; pinNo <= 53; pinNo++){// checks all the pins 10 to 53
    pinStateSTR = String(digitalRead(pinNo));
    oldpinStateSTR = "";
    oldpinStateSTR += String(stringoldstate.charAt(pinNo - 10));
    if (pinStateSTR != oldpinStateSTR) {// yes it's different
    if (pinNo == 11 and pinStateSTR == "0") { //Change-over button is pressed
    if (active == 14) Serial.println("A06");//com1
    if (active == 15) Serial.println("A12");//com2
    if (active == 16) Serial.println("A18");//nav1
    if (active == 17) Serial.println("A24"); //nav2
    if ( active == 1{ //adf
    mark = (mark + 1);
    if (mark == 13){
    mark = 14;
    }// sort out for piont in ADF
    active = 1;
    if (mark > 14)mark = 10;
    }
    if (active == 20){ //xponder
    mark = (mark + 1);
    if (mark == 13){
    mark = 9;
    }// sort out for length Xponder
    active = 1;
    if (mark > 12)mark = 12;
    }
    }// end of pin 11 sortout
    if (pinNo == 14 && pinStateSTR == "1"){// COM1
    buttonFunction=0;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, HIGH);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 15 && pinStateSTR == "1"){// COM2
    buttonFunction=1;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, HIGH);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 16 && pinStateSTR == "1"){// NAV1
    buttonFunction=2;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, HIGH);
    digitalWrite(69, LOW);
    }
    if (pinNo == 17 && pinStateSTR == "1"){// NAV2
    buttonFunction=3;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, HIGH);
    }
    if (pinNo == 18 && pinStateSTR == "1"){ // ADF
    buttonFunction=4;
    digitalWrite(63, LOW);
    digitalWrite(64, HIGH);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 19 && pinStateSTR == "1"){// DME
    buttonFunction=5;
    digitalWrite(63, HIGH);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 20 && pinStateSTR == "1"){ // Txpr
    buttonFunction=6;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, HIGH);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    // Add more "Simconnect direct" codes here.
    // now the "keys" bit ,,, notice the "26" in line above and also in line below.
    if (pinNo > 26){ // start of "Keys" bit
    Serial.print ("D");
    if (pinNo < 10) Serial.print ("0");
    Serial.print (pinNo);
    Serial.println (pinStateSTR);
    } // end of "Keys" bit
    }// end of "yes it's different"
    stringnewstate += pinStateSTR;
    }
    stringoldstate = stringnewstate;
    delay(11);
    }// end of inputpins


    void ROTARYS() {//now the bit for the rotary encoder input
    X = (quad1.position()/2);
    if (X != Xold) { // checks to see if it different
    (Xdif = (X-Xold));// finds out the difference

    if (active == 14){// Com1 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A01");
    }
    else Serial.println("A03");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A02");
    }
    else Serial.println("A04");
    }
    }
    if (active == 15){// Com2 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A07");
    }
    else Serial.println("A09");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A08");
    }
    else Serial.println("A10");
    }
    }
    if (active == 16){// Nav1 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A13");
    }
    else Serial.println("A15");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A14");
    }
    else Serial.println("A16");
    }
    }
    if (active == 17){// Nav2 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A19");
    }
    else Serial.println("A21");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A20");
    }
    else Serial.println("A22");
    }
    }
    if (active == 1{// ADF rotary encoder output
    if (digitalRead(10)==0 ) {
    if (Xdif == 1) {
    mark = (mark - 1);
    active = 2;
    if (mark == 13) mark =12;
    }
    if (Xdif == -1){
    mark = (mark + 1);
    active = 2;
    if (mark == 13) mark =14;
    }
    if (mark > 14) mark = 14;
    if (mark < 10) mark = 10;
    }
    else{
    if (Xdif == 1) {
    if (mark == 10) {
    Serial.println("A29");
    }
    if (mark == 11) {
    Serial.println("A30");
    }
    if (mark == 12) {
    Serial.println("A31");
    }
    if (mark == 14) {
    Serial.println("A32");
    }
    }
    if (Xdif == -1){
    if (mark == 10){
    Serial.println("A25");
    }
    if (mark == 11){
    Serial.println("A26");
    }
    if (mark == 12){
    Serial.println("A27");
    }
    if (mark == 14){
    Serial.println("A28");
    }
    }
    }
    }
    if (active == 20){// Xponder rotary encoder output
    if (digitalRead(10)==0 ) {
    if (Xdif == 1) {
    mark = (mark - 1);
    active = 2;
    }
    if (Xdif == -1){
    mark = (mark + 1);
    active = 2;
    }
    if (mark > 12) mark = 12;
    if (mark < 9) mark = 9;
    }
    else{
    if (Xdif == 1) {
    if (mark == 9) {
    Serial.println("A38");
    }
    if (mark == 10) {
    Serial.println("A39");
    }
    if (mark == 11) {
    Serial.println("A40");
    }
    if (mark == 12) {
    Serial.println("A41");
    }
    }
    if (Xdif == -1){
    if (mark == 9){
    Serial.println("A34");
    }
    if (mark == 10){
    Serial.println("A35");
    }
    if (mark == 11){
    Serial.println("A36");
    }
    if (mark == 12){
    Serial.println("A37");
    }
    }
    }
    }


    if (quad1.position() > 1000){ // zero the rotary encoder count if too high or low
    quad1.position(0);
    }
    if (quad1.position() < -1000){
    quad1.position(0);
    }
    Xold = X; // overwrites the old reading with the new one.
    }
    }// end of rotarys







    void ACTIVE(){
    if (active != activeold)
    activeold = active;
    if (digitalRead(14)==0 and active != 14) {
    active = 14;
    }


    if (digitalRead(15)==0 and active != 15) {
    active = 15;
    }


    if (digitalRead(16)==0 and active != 16) {
    active = 16;
    }
    if (digitalRead(17)==0 and active != 17) {
    active = 17;
    }
    if (digitalRead(1==0 and active != 1 {
    active = 18;
    }
    if (digitalRead(19)==0 and active != 19) {
    active = 19;
    }
    if (digitalRead(20)==0 and active != 20) {
    active = 20;
    }
    } // end of active

  4. #4
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    Jan 2016
    Location
    France
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Instruction From CARD

    Thanks for your very fast answer. Here is my code (merge of code that I found on internet, thanks to the writer ...) :
    What should I change ?

    #include "math.h"
    #include "Quadrature.h"
    #include "LedControl.h"


    Quadrature quad1(8, 9);


    LedControl led_Display_1 = LedControl(32,33,34,;


    int CodeIn;// used on all serial reads
    int X;// a rotary variable
    int Xold;// the old reading
    int Xdif;// the difference since last loop
    int active; // the mode thats active
    int activeold;
    int mark; // shows where the cursor is in the likes of ADF etc
    int buttonFunction = 1; // Mode selection


    int Count; // This variable used in loops in the EQUALS() function
    int COM1[4],COM1SB[4], COM2[4], COM2SB[4], NAV1[4], NAV1SB[4], NAV2[4],NAV2SB[4], ADF[4],Xpdr[4],DME[4];


    String Digit; // Variable as a string to take from getChar()
    String oldpinStateSTR, pinStateSTR, pinStateString, APsp, APspold, stringnewstate,stringoldstate;


    void setup()
    {
    pinMode(13,OUTPUT);
    digitalWrite(13,LOW);
    for (int doutPin = 10; doutPin <= 53; doutPin++) // setup the input pins
    {
    pinMode(doutPin, INPUT);
    digitalWrite(doutPin, HIGH);
    }
    for (int PinNo = 54; PinNo <= 69; PinNo++)// Get all the OUTPUT pins ready.
    {
    pinMode(PinNo, OUTPUT);
    }
    mark = 10;



    delay (500);
    led_Display_1.shutdown(0,false);
    delay (500);



    led_Display_1.setIntensity(0,4);


    led_Display_1.clearDisplay(0);


    Serial.begin(115200);

    }
    void loop()
    {
    {INPUTPINS();} //Check the "button pressed" section
    {ACTIVE();}
    {ROTARYS();} // go and check the rotary encoder
    if (Serial.available())
    {
    CodeIn = getChar();
    if (CodeIn == '=')
    {EQUALS();}
    }

    }


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




    void EQUALS(){ // The first identifier was "="
    CodeIn = getChar(); // Get another character
    switch(CodeIn) {// Now lets find what to do with it
    case 'A': //COMM1 Active
    Count = 0;
    while (Count < 4 ) // Counting fro 0 to 4. Five digits to store in the COM1 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.
    }
    COM1[Count] = Digit.toInt(); // Turn String Digit into an Integer and store it in the Array for later
    Count++; // add one to the count
    }
    if (active==14) // Because our display is used for multiple radios we only want it updating the display for the selected
    { // radio(s)
    led_Display_1.setDigit(0,0,COM1[0],false);
    led_Display_1.setDigit(0,1,COM1[1],false);
    led_Display_1.setDigit(0,2,COM1[2],true);
    led_Display_1.setDigit(0,3,COM1[3],false);

    }

    break;

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

    }

    break;


    case 'C': //COMM2 Active
    Count = 0;
    while (Count < 5 )
    {
    Digit = "";
    Digit += getChar();
    if (Digit ==".")
    {
    Digit = "";
    Digit += getChar();
    }
    COM2[Count] = Digit.toInt();
    Count++;
    }
    if (active==15)
    {
    led_Display_1.setDigit(0,0,COM2[0],false);
    led_Display_1.setDigit(0,1,COM2[1],false);
    led_Display_1.setDigit(0,2,COM2[2],true);
    led_Display_1.setDigit(0,3,COM2[3],false);
    }

    break;

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

    }

    break;

    case 'E': // Nav1 Active
    Count = 0;
    while (Count < 5 )
    {
    Digit = "";
    Digit += getChar();
    if (Digit ==".")
    {
    Digit = "";
    Digit += getChar();
    }
    NAV1[Count] = Digit.toInt();
    Count++;
    }
    if (active==16)
    {
    led_Display_1.setDigit(0,0,NAV1[0],false);
    led_Display_1.setDigit(0,1,NAV1[1],false);
    led_Display_1.setDigit(0,2,NAV1[2],true);
    led_Display_1.setDigit(0,3,NAV1[3],false);

    }

    break;

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

    }

    break;

    case 'G': // Nav2 Active
    Count = 0;
    while (Count < 5 )
    {
    Digit = "";
    Digit += getChar();
    if (Digit ==".")
    {
    Digit = "";
    Digit += getChar();
    }
    NAV2[Count] = Digit.toInt();
    Count++;
    }
    if (active==17)
    {
    led_Display_1.setDigit(0,0,NAV2[0],false);
    led_Display_1.setDigit(0,1,NAV2[1],false);
    led_Display_1.setDigit(0,2,NAV2[2],true);
    led_Display_1.setDigit(0,3,NAV2[3],false);

    }

    break;

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

    }

    break;

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

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

    }

    break;

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

    Xpdr[Count] = Digit.toInt();
    Count++;
    }
    if (active==1
    {
    led_Display_1.setDigit(3,7,Xpdr[0],false);
    led_Display_1.setDigit(3,6,Xpdr[1],false);
    led_Display_1.setDigit(3,5,Xpdr[2],false);
    led_Display_1.setDigit(3,4,Xpdr[3],false);
    }
    break;
    }
    }


    int INPUTPINS(){
    stringnewstate = "";
    for (int pinNo = 10; pinNo <= 53; pinNo++){// checks all the pins 10 to 53
    pinStateSTR = String(digitalRead(pinNo));
    oldpinStateSTR = "";
    oldpinStateSTR += String(stringoldstate.charAt(pinNo - 10));
    if (pinStateSTR != oldpinStateSTR) {// yes it's different
    if (pinNo == 11 and pinStateSTR == "0") { //Change-over button is pressed
    if (active == 14) Serial.println("A06");//com1
    if (active == 15) Serial.println("A12");//com2
    if (active == 16) Serial.println("A18");//nav1
    if (active == 17) Serial.println("A24"); //nav2
    if ( active == 1{ //adf
    mark = (mark + 1);
    if (mark == 13){
    mark = 14;
    }// sort out for piont in ADF
    active = 1;
    if (mark > 14)mark = 10;
    }
    if (active == 20){ //xponder
    mark = (mark + 1);
    if (mark == 13){
    mark = 9;
    }// sort out for length Xponder
    active = 1;
    if (mark > 12)mark = 12;
    }
    }// end of pin 11 sortout
    if (pinNo == 14 && pinStateSTR == "1"){// COM1
    buttonFunction=0;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, HIGH);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 15 && pinStateSTR == "1"){// COM2
    buttonFunction=1;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, HIGH);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 16 && pinStateSTR == "1"){// NAV1
    buttonFunction=2;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, HIGH);
    digitalWrite(69, LOW);
    }
    if (pinNo == 17 && pinStateSTR == "1"){// NAV2
    buttonFunction=3;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, HIGH);
    }
    if (pinNo == 18 && pinStateSTR == "1"){ // ADF
    buttonFunction=4;
    digitalWrite(63, LOW);
    digitalWrite(64, HIGH);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 19 && pinStateSTR == "1"){// DME
    buttonFunction=5;
    digitalWrite(63, HIGH);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 20 && pinStateSTR == "1"){ // Txpr
    buttonFunction=6;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, HIGH);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    // Add more "Simconnect direct" codes here.
    // now the "keys" bit ,,, notice the "26" in line above and also in line below.
    if (pinNo > 26){ // start of "Keys" bit
    Serial.print ("D");
    if (pinNo < 10) Serial.print ("0");
    Serial.print (pinNo);
    Serial.println (pinStateSTR);
    } // end of "Keys" bit
    }// end of "yes it's different"
    stringnewstate += pinStateSTR;
    }
    stringoldstate = stringnewstate;
    delay(11);
    }// end of inputpins


    void ROTARYS() {//now the bit for the rotary encoder input
    X = (quad1.position()/2);
    if (X != Xold) { // checks to see if it different
    (Xdif = (X-Xold));// finds out the difference

    if (active == 14){// Com1 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A01");
    }
    else Serial.println("A03");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A02");
    }
    else Serial.println("A04");
    }
    }
    if (active == 15){// Com2 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A07");
    }
    else Serial.println("A09");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A08");
    }
    else Serial.println("A10");
    }
    }
    if (active == 16){// Nav1 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A13");
    }
    else Serial.println("A15");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A14");
    }
    else Serial.println("A16");
    }
    }
    if (active == 17){// Nav2 rotary encoder output
    if (Xdif == 1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A19");
    }
    else Serial.println("A21");
    }
    if (Xdif == -1) {
    if (digitalRead(10)==0 ) {
    Serial.println("A20");
    }
    else Serial.println("A22");
    }
    }
    if (active == 1{// ADF rotary encoder output
    if (digitalRead(10)==0 ) {
    if (Xdif == 1) {
    mark = (mark - 1);
    active = 2;
    if (mark == 13) mark =12;
    }
    if (Xdif == -1){
    mark = (mark + 1);
    active = 2;
    if (mark == 13) mark =14;
    }
    if (mark > 14) mark = 14;
    if (mark < 10) mark = 10;
    }
    else{
    if (Xdif == 1) {
    if (mark == 10) {
    Serial.println("A29");
    }
    if (mark == 11) {
    Serial.println("A30");
    }
    if (mark == 12) {
    Serial.println("A31");
    }
    if (mark == 14) {
    Serial.println("A32");
    }
    }
    if (Xdif == -1){
    if (mark == 10){
    Serial.println("A25");
    }
    if (mark == 11){
    Serial.println("A26");
    }
    if (mark == 12){
    Serial.println("A27");
    }
    if (mark == 14){
    Serial.println("A28");
    }
    }
    }
    }
    if (active == 20){// Xponder rotary encoder output
    if (digitalRead(10)==0 ) {
    if (Xdif == 1) {
    mark = (mark - 1);
    active = 2;
    }
    if (Xdif == -1){
    mark = (mark + 1);
    active = 2;
    }
    if (mark > 12) mark = 12;
    if (mark < 9) mark = 9;
    }
    else{
    if (Xdif == 1) {
    if (mark == 9) {
    Serial.println("A38");
    }
    if (mark == 10) {
    Serial.println("A39");
    }
    if (mark == 11) {
    Serial.println("A40");
    }
    if (mark == 12) {
    Serial.println("A41");
    }
    }
    if (Xdif == -1){
    if (mark == 9){
    Serial.println("A34");
    }
    if (mark == 10){
    Serial.println("A35");
    }
    if (mark == 11){
    Serial.println("A36");
    }
    if (mark == 12){
    Serial.println("A37");
    }
    }
    }
    }


    if (quad1.position() > 1000){ // zero the rotary encoder count if too high or low
    quad1.position(0);
    }
    if (quad1.position() < -1000){
    quad1.position(0);
    }
    Xold = X; // overwrites the old reading with the new one.
    }
    }// end of rotarys







    void ACTIVE(){
    if (active != activeold)
    activeold = active;
    if (digitalRead(14)==0 and active != 14) {
    active = 14;
    }


    if (digitalRead(15)==0 and active != 15) {
    active = 15;
    }


    if (digitalRead(16)==0 and active != 16) {
    active = 16;
    }
    if (digitalRead(17)==0 and active != 17) {
    active = 17;
    }
    if (digitalRead(1==0 and active != 1 {
    active = 18;
    }
    if (digitalRead(19)==0 and active != 19) {
    active = 19;
    }
    if (digitalRead(20)==0 and active != 20) {
    active = 20;
    }
    } // end of active

  5. #5
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    Jan 2016
    Location
    France
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Instruction From CARD

    Thanks for your very fast answer. The problem com from this function, right ? :
    int INPUTPINS(){
    stringnewstate = "";
    for (int pinNo = 10; pinNo <= 53; pinNo++){// checks all the pins 10 to 53
    pinStateSTR = String(digitalRead(pinNo));
    oldpinStateSTR = "";
    oldpinStateSTR += String(stringoldstate.charAt(pinNo - 10));
    if (pinStateSTR != oldpinStateSTR) {// yes it's different
    if (pinNo == 11 and pinStateSTR == "0") { //Change-over button is pressed
    if (active == 14) Serial.println("A06");//com1
    if (active == 15) Serial.println("A12");//com2
    if (active == 16) Serial.println("A18");//nav1
    if (active == 17) Serial.println("A24"); //nav2
    if ( active == 1{ //adf
    mark = (mark + 1);
    if (mark == 13){
    mark = 14;
    }// sort out for piont in ADF
    active = 1;
    if (mark > 14)mark = 10;
    }
    if (active == 20){ //xponder
    mark = (mark + 1);
    if (mark == 13){
    mark = 9;
    }// sort out for length Xponder
    active = 1;
    if (mark > 12)mark = 12;
    }
    }// end of pin 11 sortout
    if (pinNo == 14 && pinStateSTR == "1"){// COM1
    buttonFunction=0;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, HIGH);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 15 && pinStateSTR == "1"){// COM2
    buttonFunction=1;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, HIGH);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 16 && pinStateSTR == "1"){// NAV1
    buttonFunction=2;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, HIGH);
    digitalWrite(69, LOW);
    }
    if (pinNo == 17 && pinStateSTR == "1"){// NAV2
    buttonFunction=3;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, HIGH);
    }
    if (pinNo == 18 && pinStateSTR == "1"){ // ADF
    buttonFunction=4;
    digitalWrite(63, LOW);
    digitalWrite(64, HIGH);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 19 && pinStateSTR == "1"){// DME
    buttonFunction=5;
    digitalWrite(63, HIGH);
    digitalWrite(64, LOW);
    digitalWrite(65, LOW);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    if (pinNo == 20 && pinStateSTR == "1"){ // Txpr
    buttonFunction=6;
    digitalWrite(63, LOW);
    digitalWrite(64, LOW);
    digitalWrite(65, HIGH);
    digitalWrite(66, LOW);
    digitalWrite(67, LOW);
    digitalWrite(68, LOW);
    digitalWrite(69, LOW);
    }
    // Add more "Simconnect direct" codes here.
    // now the "keys" bit ,,, notice the "26" in line above and also in line below.
    if (pinNo > 26){ // start of "Keys" bit
    Serial.print ("D");
    if (pinNo < 10) Serial.print ("0");
    Serial.print (pinNo);
    Serial.println (pinStateSTR);
    } // end of "Keys" bit
    }// end of "yes it's different"
    stringnewstate += pinStateSTR;
    }
    stringoldstate = stringnewstate;
    delay(11);
    }// end of inputpins

  6. #6
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    Jan 2016
    Location
    France
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Instruction From CARD

    Thanks for your very fast answer !
    It's a press button.
    Here is my code :https://mega.nz/#F!Vo0UgLJA!Xu2hGIC6I6n9oqvuBW2Y7w


  7. #7
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    Jan 2016
    Location
    France
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Instruction From CARD

    Quote Originally Posted by BuzziBi View Post
    This comes from this part of the code:
    if (KpinNo != 13){
    Serial.print ("D");
    if (KpinNo < 10) Serial.print ("0");
    Serial.print (KpinNo);
    Serial.println (KpinStateSTR);
    I have nothing like serial.print("D")

  8. #8
    150+ Forum Groupie BuzziBi's Avatar
    Join Date
    Mar 2013
    Location
    Norway
    Posts
    275
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Instruction From CARD

    The line 28:
    for (int doutPin = 10; doutPin <= 53; doutPin++) // setup the input pins

    Line 325 to 328
    for (int pinNo = 10; pinNo <= 53; pinNo++){// checks all the pins 10 to 53
    pinStateSTR = String(digitalRead(pinNo));
    oldpinStateSTR = "";
    oldpinStateSTR += String(stringoldstate.charAt(pinNo - 10));

    Line 425:
    Serial.print ("D");
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  9. Thanks vincedobro thanked for this post
    Likes vincedobro liked this post
  10. #9
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    Jan 2016
    Location
    France
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Instruction From CARD

    What should I do to avoid this problem ?

  11. #10
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    Jan 2016
    Location
    France
    Posts
    12
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Instruction From CARD

    I've put this instruction in comment (*/).
    It's seems working. Thanks sir.
    I've an another question : I have a digit segment displays. I would active them has it's coded in the script. When i push the button (NAV or COM or anything else) nothing appears on the display. But the LED corresponding to the mode is on and the swipe or the encoder works fine. Do you know where does it come from ?

Page 1 of 2 12 LastLast