Results 1 to 6 of 6
  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

    arduino uno with two lcds NAV1 and COM1

    hi guys
    lets see if someone can help me. i'm trying to get 2 lcds 1602a type to work together at same time with arduino uno, one showing nav1 frequency and standby and the other showing com1 frequency and standby dont need encoders or buttons i just need it to show nav1 and com1. so have been trying to change the code and i do have nav1 working but not the com1. can you guys look at the code and show me what am i doing wrong...

    Code:
    #include 
    
    // initialize the library with the numbers of the interface pins
    LiquidCrystal lcd1(7, 6, 5, 4, 3, 2);
    LiquidCrystal lcd2(13, 12, 11, 10, 9, 8);
    
    int j1;
    int j2;
    int pinState;
    int pinNo; 
    int doutpin;
    String oldpinStateSTR, pinStateSTR, stringnewstate,stringoldstate, nav1, nav1old, nav1sb, nav1sbold, com1, com1old, com1sb, com1sbold, airsp, airspold, altit, altitold;
    ;
    
    void setup() 
    {
      // set up the LCD's number of columns and rows: 
      lcd1.begin(16, 2);
      lcd2.begin(16, 2);
      // Print a message to the LCD.
      delay (11);
      lcd1.print("Freq  NAV1  Stby");
      lcd2.print("Freq  COM1  Stby");
      delay (11);
      lcd1.setCursor(0, 1);
      lcd2.setCursor(0, 1);
      delay (11);
      lcd1.print("Boeing<-->7378NG");
      lcd2.print("Cptain<-->FPires");
      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 == 'G'){     // 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);
                       lcd2.setCursor(0, 0); //sets the cursor position for the first letter
                       delay (11);
                       lcd2.print(airsp); //Prints the data to the LCD
                       airspold = airsp; // Writes the current reading to the "old" string.
                        }        
                  }
        
       if (j1 == 'p'){     // 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);
                       lcd2.setCursor(8, 0);
                       delay (11);
                       lcd2.print(altit);
                       altitold = altit;
                        }        
                  } 
        
          if (j1 == 'h'){ //  Found the reading "nav1 frequency"
                   delay (11);
                   nav1 = "";
                   nav1 += char(Serial.read());
                   nav1 += char(Serial.read());
                   nav1 += char(Serial.read());
                   nav1 += char(Serial.read());
                   nav1 += char(Serial.read());
                   nav1 += char(Serial.read());
                   
                   nav1 += (""); //pads it up to 8 caracters
                   if (nav1 != nav1old){
                       //delay (11);
                       lcd1.setCursor(0, 1);
                       delay (11);
                       lcd1.print(nav1);
                       nav1old = nav1;
                       }
                    }
                     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 += (""); //pads it up to 8 caracters
                   if (com1 != com1old){
                       //delay (11);
                       lcd2.setCursor(0, 1);
                       delay (11);
                       lcd2.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 += (" "); //pads it up to 8 caracters
                  if (com1sb != com1sbold){
                       //delay (11);
                       lcd2.setCursor(10, 1);
                       delay (11);
                       lcd2.print(com1sb);
                       com1sbold = com1sb;
                        }        
                  }
          if (j1 == 'i'){ // Found the reading "nav1 stand-by" 
                  delay (11);
                  nav1sb = "";
                  nav1sb += char(Serial.read());
                  nav1sb += char(Serial.read());
                  nav1sb += char(Serial.read());
                  nav1sb += char(Serial.read());
                  nav1sb += char(Serial.read());
                  nav1sb += char(Serial.read());
                  
                  nav1sb += (" "); //pads it up to 8 caracters
                  if (nav1sb != nav1sbold){
                       //delay (11);
                       lcd1.setCursor(10, 1);
                       delay (11);
                       lcd1.print(nav1sb);
                       nav1sbold = nav1sb;
                        }        
                  }
          
       }
     
    
      
    }

  2. #2
    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: arduino uno with two lcds NAV1 and COM1

    Everything looks fine. I noticed you are printing airspeed & altitude on the first line; COM1 & stdby on the second line. Are the items on the first line printing? If not, does your lcd2.print("Cptain<-->FPires") from you're setup statement work?

  3. #3
    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: arduino uno with two lcds NAV1 and COM1

    Yes i've left the airspeed and altitude code in but i dont have any interest in using so i will probably delete it from the code. And to answer your question yes it does show the lcd2.print you've asked. What do you think is wrong? Is it the doutpin? What if i make both lcds share the same pins? Will it work like i want to? Thanks for your help

    ps- so what i have now is the lcd1 showing freq nav1 stby in the first line and the bottom line shows the nav1 values but the lcd2 shows freq com1 stby in the first line but the bottom line does not change the lcd2.print of the void setup and so it does not show the com1 data
    Last edited by pirata1906; 06-16-2013 at 11:50 AM. Reason: Forgot something

  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: arduino uno with two lcds NAV1 and COM1

    good news i've tried today changing the int doutPin = 8; doutPin <= 19; doutPin++ to int doutPin = 14; doutPin <= 19; doutPin++
    and now works very good

  5. #5
    New Member
    Join Date
    Jun 2013
    Location
    London
    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

    Re: arduino uno with two lcds NAV1 and COM1

    Hi Jim, pirata et al.

    I have been working off and on on an instrument panel over the last 2 yrs and tonight i finally got to the stage where i had all my 7seg displays working with the insightful help of jims pages and some other sites on the max7219 chips.

    Anyway, while I was working and designing I also looked into using some LCD displays. Your method is perfect, but I have a suggestion that worked for me. I was playing around with the idea of using less pins to free up pins for other uses. I then read up on exactly how these displays are written two. Bear in mind this was about a year and a half ago so I might not have all the details correct. But what I think I did was use the same set of pins for 4 LCDs except having a separate enable pin for each one.

    So what I then did was create a single LCD object and write the necessary details to it. However each time I would make the enable pin of the LCD which needed to display the data high just before i sent the write command. This enabled me to have all 4 LCDs working in a sort of round robin way, or multiplex if you will.

    Hope this helps.

    Take care and good luck.

  6. #6
    New Member



    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    2
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: arduino uno with two lcds NAV1 and COM1

    Multiple displays on Uno:4 LCD displays on 1 Arduino