SEVEN SEGMENT DISPLAY COUNTDOWN USING ARDUINO UNO. (Code ...

SEVEN SEGMENT DISPLAY COUNTDOWN USING ARDUINO UNO. (Code ... © GPL3+

A common but useful component

  • 1 view
  • 0 comments
  • 1 respect

Components and supplies

Apps and online services

About this project

Posted on January 8, 2017 by electromaniaweb

The main advantage of light emitting diodes is that because of their small die size, several of them can be connected together within one small and compact package producing what is generally called a 7-segment Display.

The 7-segment display, also written as “seven segment display”, consists of seven LEDs (hence its name) arranged in a rectangular fashion as shown. Each of the seven LEDs is called a segment because when illuminated the segment forms part of a numerical digit (both Decimal and Hex) to be displayed. An additional 8th LED is sometimes used within the same package thus allowing the indication of a decimal point, (DP) when two or more 7-segment displays are connected together to display numbers greater than ten.

Two types of SSD’s are available.

  • Common cathode Seven segment display

2. Common anode Seven segment display.

For now we will use a common anode seven segment display.

ASSEMBLING THE CIRCUIT.

  • Firstly we will start by connecting the first pin on the seven segment display to the 2nd pin in the arduino. In likewise fashion we will connect the second to the third pin slot in arduino.
  • Now comes the tricky part, we have to connect the third pin on the seven segment display to the pin on the opposite side of it. And then connect them both to the ground slot in the arduino.
  • Now in like wise fashion we will keep joining the pin in the seven segment display to the arduino till pin 9 of the arduino.

    We are all done with assembling the circuit.

    Now there is an interesting breadboarding technique that can be used in this particular project. Using the same code mentioned above we can use two and up to four, Seven segment display countdown. Only con is that we will require an inexplicable amount of jumper wires.

    I will show you how I did it for two SSD’s you can try on for as many as you like if you have those many jumper wires and breadboard.

    What I did here was to connect the pin wire of the arduino to a slot in the breadboard and then join that slot to the two SSD’s simultaneously so that both of the SSD’s get the same common from the code and perform the same function.

    Here you can clearly see what I did. But this was just to brush up your basic breadboarding skills and to be honest becomes very tiring and messy with so many wires.

    Code

    codeArduino
    int A = 7; //Defines all pins on the Arduino Uno board in order of connection.
    int B = 6;
    int C = 4; // DOT is pin 5, not used in this example.
    int D = 3;
    int E = 2;
    int F = 8;
    int G = 9;
    byte num0 = 0x3F; //Hexadecimal format based upon the A-G, 0-9 Chart in excel and the wiring // of the segment (refer to the on/off table image below).
    byte num1 = 0x6;
    byte num2 = 0x5B;
    byte num3 = 0x4F;
    byte num4 = 0x66;
    byte num5 = 0x6D;
    byte num6 = 0x7C;
    byte num7 = 0x7;
    byte num8 = 0x7F;
    byte num9 = 0x6F;
    void on(byte num) // This function turns on the correct pins to display numbers passed to it // through the variable “num”.
    {
    int result = bitRead(num, 0); // Read the first binary entry in num and stores it in result.
    if (result == 1) // Check to see if this segment should be on.
    {digitalWrite(A, HIGH);} // Turns on the segment.
    else // Otherwise, it turns it off.
    {digitalWrite(A, LOW);} // Turns segment off.
    result = bitRead( num, 1); // Same thing for the 6 remaining segments.
    if (result == 1)
    {digitalWrite(B, HIGH);}
    else
    {digitalWrite(B, LOW);}
    result = bitRead( num, 2);
    if (result == 1)
    {digitalWrite(C, HIGH);}
    else
    {digitalWrite(C, LOW);}
    result = bitRead( num, 3);
    if (result == 1)
    {digitalWrite(D, HIGH);}
    else
    {digitalWrite(D, LOW);}
    result = bitRead( num, 4);
    if (result == 1)
    {digitalWrite(E, HIGH);}
    else
    {digitalWrite(E, LOW);}
    
    result = bitRead( num, 5);
    if (result == 1)
    {digitalWrite(F, HIGH);}
    else
    {digitalWrite(F, LOW);}
    
    result = bitRead( num, 6);
    if (result == 1)
    {digitalWrite(G, HIGH);}
    else
    {digitalWrite(G, LOW);}
    }
    void setup() { // Our setup routine
    pinMode(A, OUTPUT); // Making all pins outputs
    pinMode(B, OUTPUT);
    pinMode(C, OUTPUT);
    pinMode(D, OUTPUT);
    pinMode(E, OUTPUT);
    pinMode(F, OUTPUT);
    pinMode(G, OUTPUT);
    pinMode(10,OUTPUT);
    }
    void loop() { // Loops forever
    on(num0); // Passing “num0” to the function “on()” defined above to display “0”
    delay(500); // Delay for 1 second to see the “0”
    on(num1); // Change to “1”
    delay(500);
    on(num2);
    delay(500);
    on(num3);
    delay(500);
    on(num4);
    delay(500);
    on(num5);
    delay(500);
    on(num6);
    delay(500);
    on(num7);
    delay(500);
    on(num8);
    delay(500);
    on(num9);
    delay(500);
    }
    

    Comments

    Similar projects you might like

    Control a 7 Segment Display with a keypad!

    Project tutorial by Isaac100

    • 10,859 views
    • 17 comments
    • 18 respects

    GPS Location Display With GPS And TFT Display Shields

    Project tutorial by Boian Mitov

    • 9,785 views
    • 5 comments
    • 24 respects

    Matrix Keypad With 7 Segment Display

    by David A Riewe

    • 7,129 views
    • 1 comment
    • 9 respects
    Add projectSign up / Login