Results 1 to 9 of 9
  1. #1
    Our new friend needs to reach 10 posts to get to the next flight level
    Join Date
    Jan 2011
    Location
    florida usa
    Posts
    5
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Help with 7 segment LED radio display

    I have written a sketch for a radio display with LED display. It writes the correct numbers but just as a flash and will not stay lit.
    Could some one help me with why it will not stay displayed.
    The code is..
    Code:
    #include "SevSeg.h"
    
    SevSeg sevseg; //Instantiate a seven segment controller object
    
    
    
    
    int CodeIn;
    String numberD, number;
    void setup() {
      byte numDigits = 5;   
      byte digitPins[] = {49, 50, 51, 52, 53};
      byte segmentPins[] = {41, 42, 43, 44, 45, 46, 47, 48};
      
      sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);
      sevseg.setBrightness(90);
      
      Serial.begin(115200);
    }
    
    
    void loop() {
      
      CodeIn = GetChar();
        if (CodeIn == '=') {// The first identifier is "=" 
         CodeIn = GetChar();
         if (CodeIn == 'B'){// Second identifier is "B"
         number = "";
         number += GetChar();
         number += GetChar();
         number += GetChar();
         number += GetChar();
         number += GetChar();
       number += GetChar();
         float numberD = number.toFloat();
         Serial.println(numberD);
         sevseg.setNumber(numberD, 2);
         }
         
      
        sevseg.refreshDisplay();
        }
    }
    
    
    char GetChar() //Serial Read Function
    {
      while(Serial.available() == 0);
      return(Serial.read());
    }
    Thanks
    Steven

  2. #2
    150+ Forum Groupie
    Join Date
    Nov 2013
    Location
    Evansville, Indiana
    Posts
    243
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: LED radio display

    Move the
    sevseg.refreshDisplay(); down below the bracket that it sits above.

    So that it is in the LOOP but outside the IF statement brackets.

    Right now, when there is no "=" it does not get refreshed.


    ~Fess


    I will only ever be, half the Geek that I wished I was.
    TheGeekForge.Com

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

    Re: LED radio display

    Thank you Fess for the reply.
    That seems so logical however it did not work.
    I moved sevseg.refreshDisplay(); out of the if statement but still in the void loop with the same results.
    I even tried moving Serial.println(numberD); and sevseg.setNumber(numberD, 2); to the same spot.
    Still only get a flash of the radio frequency. My debug Serial.println(numberD); is showing the correct stuff in the serial monitor.

    Tried a while statement around the sevseg.refreshDisplay(); but cant figure out how to break out of it when new info comes in. It did keep the display that way just cant get it to change with new info.

    This just makes no sense. Any other ideas?

    Steven

  4. #4
    75+ Posting Member
    Join Date
    Aug 2015
    Location
    Montreal
    Posts
    106
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: LED radio display

    Your numberD variable lives only within the if where your serial print is, not outside. Create another, global variable that you set with this value and feed it every loop to your seven segment. Or, at least, do not create a second variable with the same name. Why a global string and a local float both named numberD?


    That should help. Right now it seems you are pushing an empty variable to be displayed.

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

    Re: LED radio display

    Still not working.
    SimSupervisor: I just didnt notice the "numberD" being in the string deceleration. I was moving code around so much trying to get it to work.

    this is the current code, still just a flash of the correct numbers, but not staying lit.
    Code:
    #include "SevSeg.h"
    
    SevSeg sevseg; //Instantiate a seven segment controller object
    
    
    
    
    int CodeIn;
    String number;
    float numberD;
    
    
    
    
    
    
    void setup() {
      byte numDigits = 5;   
      byte digitPins[] = {49, 50, 51, 52, 53};
      byte segmentPins[] = {41, 42, 43, 44, 45, 46, 47, 48};
      
       sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);
       sevseg.setBrightness(90);
      
      Serial.begin(115200);
    }
    
    
    void loop() {
    
    
      
      CodeIn = GetChar();
        if (CodeIn == '=') {// The first identifier is "=" 
         CodeIn = GetChar();
         if (CodeIn == 'B'){// Second identifier is "B"
    	 number = "";
    	 number += GetChar();
    	 number += GetChar();
    	 number += GetChar();
    	 number += GetChar();
    	 number += GetChar();
       number += GetChar();
       numberD = number.toFloat();
       Serial.println(numberD);
    	 }
    	}
       sevseg.setNumber(numberD, 2);
       sevseg.refreshDisplay();
    
    
    }
    
    
    
    
    
    
    char GetChar() //Serial Read Function
    {
      while(Serial.available() == 0);
      return(Serial.read());
    }

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

    Re: LED radio display

    Well, I got it fixed.
    I used some code from others that use the MAX7219 displays and changed it up a bit.
    got this and it works...
    Code:
    #include "SevSeg.h"
    
    SevSeg sevseg; //Instantiate a seven segment controller object
    
    
    
    
    int CodeIn;      // used on all serial reads from Jim's code
    String Digit, number;    
    int numberSBY;
    int Count;       // This variable used in loops in the EQUALS() function
    int comOneSBY[6];   // comOneSBY[6] is an array of the 5 digits that are the coms sets
    
    
    
    
    void setup() {
      byte numDigits = 5;   //Number of digets
      byte digitPins[] = {49, 50, 51, 52, 53}; //Pins for the digits common
      byte segmentPins[] = {41, 42, 43, 44, 45, 46, 47, 48}; // pins for the segments a-g decimal at the end
      
       sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);
       sevseg.setBrightness(90);
      
      Serial.begin(115200);
    }
    
    
    void loop() 
    { 
        if (Serial.available()) 
        {
            CodeIn = getChar();
            if (CodeIn == '=') 
            {
                EQUALS();              // The first identifier is "="
            } 
    	}
    	
    	sevseg.setNumber(numberSBY, 2); //set the desplayed numbers
        sevseg.refreshDisplay(); //show the numbers
    }
    
    
    char getChar()// Get a character from the serial buffer
    {
      while(Serial.available() == 0);   // wait for data
      return((char)Serial.read());      // Thanks Doug
    } 
    
    
    void EQUALS()               // The first identifier was "="
    {  
        CodeIn = getChar();     // Get another character
        switch(CodeIn)          // Now lets find what to do with it
        {
            case 'B':           //  com1 stby frequency
                Count = 0;               // clear the Count
                while (Count < 6)        // we will count to 6 from 0 to 5
                {
                    Digit = "";          // clears the string variable Digit
                    Digit += getChar();  // Makes the string Digit what ever getChar() is holding
                     
                    comOneSBY[Count] = Digit.toInt(); // Turns the string Digit into an Integer and
                                                       // then stores it in the Array comOneSBY[] 0,1,2,3,4,5
                    Count++;
                }
                number = "";
                number += comOneSBY[0];   // First digit 
                number += comOneSBY[1];   // Second digit 
                number += comOneSBY[2];   // Third digit  
                //number += comOneSBY[3];   // Fourth digit is a decimal point and is not needed 
                number += comOneSBY[4];   // Fifth digit 
                number += comOneSBY[5];   // Sixth digit 
                // Serial.println(number); // debug
    			numberSBY = number.toInt(); // make it an intraga 
            break;
    		
    	}
    }
    Now to more of a glutton to punishment, add the active frequency!

    Thanks all,
    Steven

  7. #7
    75+ Posting Member
    Join Date
    Aug 2015
    Location
    Montreal
    Posts
    106
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: LED radio display

    Please keep us posted. I have seven segment displays to come and will be looking at implementing my own radio panels soon, if I can spare a few headeach it wouldn't be a bad thing.

  8. #8
    150+ Forum Groupie
    Join Date
    Nov 2013
    Location
    Evansville, Indiana
    Posts
    243
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: LED radio display

    That looks like some of my code, using an array to keep the digits.

    ~Fess
    I will only ever be, half the Geek that I wished I was.
    TheGeekForge.Com

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

    Re: LED radio display

    Quote Originally Posted by Fess_ter View Post
    That looks like some of my code, using an array to keep the digits.

    ~Fess
    That just might be.
    Although the thing has became organic and changed. Its no longer a comms display.
    One of my 7 digits is no good, so now I have an RPM display and DME.
    I also added fuel gauges and a EGT by way of servos.

    Steven