Results 1 to 2 of 2
  1. #1
    New Member
    Join Date
    Dec 2013
    Location
    Brasil
    Posts
    1
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Thumbs down Help to set up a switch.

    Guys,

    I've been reading all the Jim's paperwork (Thank you Jim), but I was not able to get my switch working.
    The Arduino code is OK, the serial monitor shows the commands in the right time but unfortunatelly the FS does not responde to the command.

    Any toughts on how to solve it?

    Code:
    int KpinNo;
    int KoutPin;
    
    
    String KoldpinStateSTR, KpinStateSTR, Kstringnewstate, Kstringoldstate;
    
    
    void setup()
    {
        Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
    
    
        for (int KoutPin = 6; KoutPin < 70; KoutPin++)
       {
          pinMode(KoutPin, INPUT);
          digitalWrite(KoutPin, HIGH); 
       }
       
       Serial.begin(115200);
    }
    
    
    void loop(){
      Kstringnewstate = "";
      for (int KpinNo = 6; KpinNo < 70; KpinNo++){ //set to the input pins. (pins 6 to 70 ,, change for Uno cards)
        KpinStateSTR = String(digitalRead(KpinNo)); 
        KoldpinStateSTR = String(Kstringoldstate.charAt(KpinNo - 6));// set to the first pin read (The 6)
        if (KpinStateSTR != KoldpinStateSTR)// checks if it's different to the last reading of that pinNo
        {
          if (KpinNo != 13){ // avoid using pin 13 as an input unless you know the tricks.
            if (KpinNo == 6 && KpinStateSTR == "0"){Serial.println ("C01");} //sets gear handle up
            if (KpinNo == 7 && KpinStateSTR == "0"){Serial.println ("C02");} //sets gear handle down
            //  Add more here but remember to change the figure in the next line down. (the 12)
            if (KpinNo > 12){ //Change pinNo number to same as the highest one used for simconnect codes.(the 12)
            Serial.print ("D"); 
          if (KpinNo < 10) Serial.print ("0");
          Serial.print (KpinNo);
          Serial.println (KpinStateSTR);
            }//end of 'its pinNo is greater than 12' 
          }//end of 'its not pin 13'
        }//end of 'its different'       
        Kstringnewstate += KpinStateSTR;
      }//end of 'for' loop (read the pins)
      Kstringoldstate = Kstringnewstate;
    }//end of INPUTS void

  2. #2
    500+ This must be a daytime job Jim NZ's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    764
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Help to set up a switch.

    Sooooo,, which program are you using ??
    and which serial monitor are you talking about ????
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !