Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    25+ Posting Member
    Join Date
    Jul 2012
    Location
    pt
    Posts
    66
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    flaps and spoiler position

    hi guys
    i've decided instead of having multiple leds indicating flaps position i would have the value printed into a 16x2 lcd, i thought it would be easy but i'm lost. i want to have the flap position and spoiler position in the lcd. anyone can help me?
    thanks
    best regards

  2. #2
    25+ Posting Member
    Join Date
    Jul 2012
    Location
    pt
    Posts
    66
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: flaps and spoiler position

    i'm not getting anywhere with my coding tests this my last attempt maybe someone can see what i'm doing wrong

    #include


    LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

    int CodeIn;// used on all serial reads
    int KpinNo;
    int Koutpin;
    String flaps, flapsOld;
    String gearSimple;
    String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate;


    void setup()
    {
    Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
    for (int koutPin = 2; koutPin <= 69; koutPin++)
    {
    // set up the LCD's number of columns and rows:
    lcd.begin(16, 2);
    // Print a message to the LCD.
    delay (11);
    lcd.print("testing_new_lcd!");
    delay (11);
    lcd.setCursor(0, 1);
    delay (11);
    lcd.print("Waiting_for_data");
    delay (11);

    Serial.begin(115200);
    pinMode(koutPin, INPUT);
    digitalWrite(koutPin, HIGH);
    }
    Serial.flush();
    }


    void loop() {
    if (Serial.available()) {
    CodeIn = getChar();
    if (CodeIn == '<') {LESSTHAN();}// The first identifier is "<"
    }
    } // end of void loop (The main one)

    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.

    void LESSTHAN(){ // The first identifier was "<"
    CodeIn = getChar(); // Get another character
    switch(CodeIn) {// Now lets find what to do with it
    case 'G'://Found the second identifier ("G" Flaps position)
    flaps = "";
    flaps += getChar();
    flaps += getChar();
    flaps += getChar();

    if(flaps != flapsOld)
    if(flaps == "0")
    {lcd.setCursor(0, 0); //sets the cursor position for the first letter
    delay (11);
    lcd.print(flaps); //Prints the data to the LCD
    flapsOld = flaps;
    }
    }



    }

  3. #3
    150+ Forum Groupie
    Join Date
    Apr 2011
    Location
    United States of America
    Posts
    232
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: flaps and spoiler position

    Hello Pirata.
    Just glancing at your code, 'if(flaps == "0")' will never be true. The reason: flaps will have three characters. Therefore, change to 'if(flaps == "000")'. Of course, it will only print "000" to the lcd but I'm sure you have a reason for it.

  4. #4
    25+ Posting Member
    Join Date
    Jul 2012
    Location
    pt
    Posts
    66
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: flaps and spoiler position

    yeah you are right i've missed that. i'll try later on to see if it works

  5. #5
    25+ Posting Member
    Join Date
    Jul 2012
    Location
    pt
    Posts
    66
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: flaps and spoiler position

    nope not working. can anyone please help me, i'm really having a bad time trying to get this to work.
    is it possible to have something like this working?:

    if(flaps == "000")
    {lcd.setCursor(0, 0); //sets the cursor position for the first letter
    delay (11);
    lcd.print("flaps up"); //Prints the data to the LCD


    i'm really lost on this, any help would be apreciated

  6. #6
    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: flaps and spoiler position

    I'm definitely not the pro her, but I read your code and noticed one thing:
    You have in this line told the arduino that pin 2 to 68 are used for keys.

    Code:
    {
    Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
    for (int koutPin = 2; koutPin <= 69; koutPin++) 
    { 
    And samtime telling that the LCD is on pin 2 to 7.
    I would guess that you have to change the line to
    [CODE]
    {
    Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
    for (int koutPin = 8; koutPin <= 69; koutPin++)
    {

    And, as the values from reading "G", goes from G000 to G057,
    You nead to say at which value, you want to print, what on the display.
    I'm not sure, but I think you have to write the values ​​you read from "G" to a char. Then use them in a if (flaps = ?)

    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  7. #7
    25+ Posting Member
    Join Date
    Jul 2012
    Location
    pt
    Posts
    66
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: flaps and spoiler position

    thanks very much i'll see if it's working with you advice sometimes being a newbie i make stupid mistakes, i'll try and see if it's working

  8. #8
    25+ Posting Member
    Join Date
    Jul 2012
    Location
    pt
    Posts
    66
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: flaps and spoiler position

    you were right i've tried it's working now... something as simple as that go figure, thank you very much

  9. #9
    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: flaps and spoiler position

    I edited the post. Not sure if you got everything
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  10. #10
    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: flaps and spoiler position

    I was somewhat intrigued by this issue, and threw me on a quest to write flaps position on the 1602 display, just for fun.
    I do not know if you've completed you're sketch, but since you have not posted a yet finished sketch, I will do so. (It could be that other simmers are sitting with the same problem).
    If someone manages to make the code easier, they are welcome to post a better code.
    The sketch are tested on an Arduino Mega and Link2fs Multi.

    EDIT: it is not possible to post the line for the LCD librarycode at top of the sketch.
    Remember to edit the "#include line" with the correct line(Look in the "Examples/LiquidCrystal" for the correct start for the sketch!
    Code:
     // include the library code:
    
    LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // initialize the library with the numbers of the interface pins
    
    
    int CodeIn;// used on all serial reads
    int KpinNo; 
    int Koutpin;
    
    
    String KoldpinStateSTR, KpinStateSTR, Kstringnewstate,Kstringoldstate;
    
    
    // For the LCD to display which angle flaps is set to.
    String flaps;
    int flapsi;
    
    
    /* Following flaps angles are for the Biong 747-400.
    To find flaps angles for other aircrafts, use
    Link2fs monitor, and read the values for each
    flaps position. EG. "G000" indicates that the Flaps are retracted (UP). */
    String text0 = "FLAPS  ";
    String text1 = "UP"; 
    String text2 = "2";   
    String text3 = "10";  
    String text4 = "19";  
    String text5 = "38";  
    String text6 = "48"; 
    String text7 = "57";
    
    
    void setup() 
    {
      Kstringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
      
      for (int KoutPin = 8; KoutPin < 70; KoutPin++)// Get all the pins ready for "Keys"  
      {
        pinMode(KoutPin, INPUT);
        digitalWrite(KoutPin, HIGH);  
      }
     Serial.begin(115200);
     
    // Starts the LCD and Displays "FLAPS", while waiting for String Values. 
      lcd.begin(16, 2);
      lcd.setCursor(0, 0);
      lcd.print(text0);
    }
    
    
    void loop() {
    
    
      if (Serial.available()) {
        CodeIn = getChar();
         if (CodeIn == '<') {LESSTHAN();}// The first identifier is "<"
      }
    }
    char getChar()// Get a character from the serial buffer
    {
      while(Serial.available() == 0);// wait for data
      return((char)Serial.read());// Thanks Doug
    }
    
    
    void LESSTHAN(){    // The first identifier was "<"
    CodeIn = getChar(); // Get another character
      switch(CodeIn) {// Now lets find what to do with it
    /* OBS! 
    While Link2fs might display such as "G028", you can not use this value!
    Octals value are in the range 0-7, so 08 and 09 would always be unknown octal constant by the compiler.
    Therefore, you must use "28" in you're if statement.  
    */
     case 'G'://Found the second identifier "Flaps"
         
          flaps = "";
          flaps += getChar();
          flaps += getChar();
          flaps += getChar();
          flapsi = flaps.toInt(); // convert it to an integer (Thanks Phill)
          
         if (flapsi == 00){
              lcd.begin(16, 2);         // Set up the LCD's number of columns and rows:
              lcd.setCursor(0, 0);      // Place the cursor 1. line, first place.
              lcd.print(text0 + text1); // Print the Values from String: text0(FLAPS) and text1(UP).
              }
          if (flapsi == 02){
              lcd.begin(16, 2);
              lcd.setCursor(0, 0);
              lcd.print(text0 + text2);
              }
          if (flapsi == 10){
              lcd.begin(16, 2);
              lcd.setCursor(0, 0);
              lcd.print(text0 + text3); 
              }
          if (flapsi == 19){ 
              lcd.begin(16, 2);
              lcd.setCursor(0, 0);
              lcd.print(text0 + text4); 
             }
          if (flapsi == 38){
              lcd.begin(16, 2);
              lcd.setCursor(0, 0);
              lcd.print(text0 + text5); 
             }
          if (flapsi == 48){
              lcd.begin(16, 2);
              lcd.setCursor(0, 0);
              lcd.print(text0 + text6); 
             }
          if (flapsi == 57){
              lcd.begin(16, 2);
              lcd.setCursor(0, 0);
              lcd.print(text0 + text7);
             }     
      } // End off case G.
      } // End off void LESSTHAN.
    Last edited by BuzziBi; 11-24-2013 at 09:06 AM. Reason: error uploading code
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

Page 1 of 2 12 LastLast