Results 1 to 5 of 5
  1. #1
    New Member
    Join Date
    Feb 2014
    Location
    England
    Posts
    3
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Altimeter and speedo

    I'm pulling my hair out now. Is it possible to display my speed and altitude on an 16x2 lcd screen? I think I've figured inputs out and outputs with leds but this is too much! I've used Arduino many times before with lcd's so I'm not new to that just cant figure this one out. Thanks in advance.

  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: Altimeter and speedo

    Hei neilthegooner
    This sketch is from Jims "link2fs_inout_v4", the "pde_inout_v4.ino".
    I guess this is what you are looking for?
    Code:
    /*  
     ======================================================
     
     This sketch prints the airspeed, altitude,
     com1. frequency and com1. standby frequency to the LCD.
     
     It is set up to use with the Uno card but it will also run as-is on the Mega using
     the pins up to No. 19.
     If you have a Mega card and want all the pins, then
     there are only 3 things to change,,,
     where it says <= 19  change that to read <= 69  (on 2 lines)
     also,,
     stringoldstate = "1111111111111111 etc" you need to have the appropriate one active.
     
     =======================================================
     
     This example code is in the public domain.
     
     */
    
    
    // include the library code:
    
    
    
    
    
    
    
    
    #include 
    
    
    // initialize the library with the numbers of the interface pins
    LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
    
    
    int j1;
    int j2;
    int pinState;
    int pinNo; 
    int doutpin;
    String oldpinStateSTR, pinStateSTR, stringnewstate,stringoldstate, com1, com1old, com1sb, com1sbold, airsp, airspold, altit, altitold;
    
    
    void setup() 
    {
      // set up the LCD's number of columns and rows: 
      lcd.begin(16, 2);
      // Print a message to the LCD.
      delay (11);
      lcd.print("Hi_from_Jim_:)__");
      delay (11);
      lcd.setCursor(0, 1);
      delay (11);
      lcd.print("Waiting_for_data");
      delay (11);
      // the line below is for the Uno card
      stringoldstate = "1111111111111111111";
      //the line below is for the mega card 
      //stringoldstate = "111111111111111111111111111111111111111111111111111111111111111111111";
      
      Serial.begin(115200);  
      for (int doutPin = 8; doutPin <= 19; doutPin++)  
        {  
       pinMode(doutPin, INPUT);
       digitalWrite(doutPin, HIGH);  
        }  
    Serial.flush(); 
    }
    
    
    void loop() {
      // read the oldest byte in the serial buffer:
       if (Serial.available() > 0) {
        j1 = Serial.read();
        if (j1 == 'W'){     // Found the reading "airspeed indicated"
                  delay (11); // It seems to need a delay here
                  airsp = "";
                  airsp += char(Serial.read());
                  airsp += char(Serial.read());
                  airsp += char(Serial.read());
                  airsp += ("  "); //pads it up to 5 caracters
                  airsp += ("   ");  //pads it up to 8 caracters            
                  if (airsp != airspold){  // checks to see if its different to the "old" reading
                      // delay (11);
                       lcd.setCursor(0, 0); //sets the cursor position for the first letter
                       delay (11);
                       lcd.print(airsp); //Prints the data to the LCD
                       airspold = airsp; // Writes the current reading to the "old" string.
                        }        
                  }
        
       if (j1 == 'C'){     // Found the reading "altitude"
                  delay (11);
                  altit = "";
                  altit += char(Serial.read());
                  altit += char(Serial.read());
                  altit += char(Serial.read());
                  altit += char(Serial.read());
                  altit += char(Serial.read());
                  altit += ("   "); //pads it up to 8 caracters
                  if (altit != altitold){
                       //delay (11);
                       lcd.setCursor(8, 0);
                       delay (11);
                       lcd.print(altit);
                       altitold = altit;
                        }        
                  } 
        
          if (j1 == 'd'){ //  Found the reading "Com1 frequency"
                   delay (11);
                   com1 = "";
                   com1 += char(Serial.read());
                   com1 += char(Serial.read());
                   com1 += char(Serial.read());
                   com1 += char(Serial.read());
                   com1 += char(Serial.read());
                   com1 += char(Serial.read());
                   com1 += char(Serial.read());
                   com1 += (" "); //pads it up to 8 caracters
                   if (com1 != com1old){
                       //delay (11);
                       lcd.setCursor(0, 1);
                       delay (11);
                       lcd.print(com1);
                       com1old = com1;
                       }
                    }
          if (j1 == 'e'){ // Found the reading "Com1 stand-by" 
                  delay (11);
                  com1sb = "";
                  com1sb += char(Serial.read());
                  com1sb += char(Serial.read());
                  com1sb += char(Serial.read());
                  com1sb += char(Serial.read());
                  com1sb += char(Serial.read());
                  com1sb += char(Serial.read());
                  com1sb += char(Serial.read());
                  com1sb += (" "); //pads it up to 8 caracters
                  if (com1sb != com1sbold){
                       //delay (11);
                       lcd.setCursor(8, 1);
                       delay (11);
                       lcd.print(com1sb);
                       com1sbold = com1sb;
                        }        
                  }
          
       }
     
    // Now the bit for the "keys" input
      stringnewstate = "";
      for (int pinNo = 8; pinNo <= 19; pinNo++){
      pinStateSTR = String(digitalRead(pinNo)); 
    
    
      oldpinStateSTR = String(stringoldstate.charAt(pinNo - 8));
     
     if (pinStateSTR != oldpinStateSTR)
         {
        Serial.print ("D"); 
        if (pinNo < 10) Serial.print ("0");
        Serial.print (pinNo);
        Serial.print (pinStateSTR);
        delay(11);
         }
     stringnewstate += pinStateSTR;
     }
     
    stringoldstate = stringnewstate;
      delay(11);
      
    }
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  3. #3
    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: Altimeter and speedo

    Buzzi that code is for the old "inOut" program which is now "dead" so it wont work for the "Multi".
    The old "inOut" program was removed from my site some time ago with the "Multi" taking it's place.

    Neil, have a play with this ,, it's a file I forgot to include with the demo's for the Multi.

    http://jimspage.co.nz/Multi_LCD_simple__demo.zip

    Cheers ,, Jim
    www.jimspage.co.nz/intro.htm
    All this and Liz still loves me ! !

  4. Thanks BuzziBi thanked for this post
  5. #4
    New Member
    Join Date
    Feb 2014
    Location
    England
    Posts
    3
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Altimeter and speedo

    Thanks guys will have a look through these. This is such a fantastic piece of software, so much I could do and build with it my imagination is running wild!! But I'll have to wait 10 years for the kids to move out for a spare room!

  6. #5
    New Member
    Join Date
    Feb 2014
    Location
    England
    Posts
    3
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: Altimeter and speedo

    Cracked it!!! Thanks for your help guys!