Introduction

7-SEGMENT DISPLAY

How many times did you see a clock displaying minutes, hours and seconds and start wondering how it can be possible to display a clock with such a large display?

How many times did you see a movie where someone needs to deactivate a bomb? The hero watches the display as time ticks by, each second more precious than the previous one.

Well, if you notice, all those bombs in movies have seven-segment displays.

It has to be! Otherwise, how could a hero possibly know how much time he has left?

The seven segments displays are the oldest yet one of the efficient types of display used in embedded applications.

This display has nothing more than 8 LEDs inside it.

These 8 LEDs are separated into each segment which can be named as a, b, c, d, e, f, g, GND. These entire 8 segment LEDs have one end of their pins pulled out of the module as shown below and the other ends are connected together and pulled out as the Common pin.

So to make an LED of a particular segment glow we just have to power a common pin along with the segment pin.

This way we can power more than one segment at a time to represent the numeric number 0-9 and also few Alphabets as well.

The numerical digits 0 to 9 are the most common characters displayed on seven-segment displays. The most common patterns used for each of these is:

The numerals 6 and 9 may be represented by two different glyphs on seven-segment displays, with or without a 'tail', and the numeral 7 also has two versions, with or without segment F:

Seven-segment displays are widely used in:

  • Digital clocks
  • Electronic meters
  • Basic calculators
  • Other electronic devices that display numerical
  • 7-SEGMENT DISPLAY PINOUT

    INTERFACIG DIAGRAM

    This circuit will display numbers from 0 to 9 and vice-versa And it will be done in loops means it will continue until you can stop the whole system to shut down.

    Sketch for Control of 7-Segment Display

    It will display numbers upward and downward. This sketch is used to test your 7 segment.

           
          int disp_pin[7];  /* array for a-g pins of 7-Segment display */
        void define_segment_pins(int a, int b, int c, int d, int e, int f, int g)/* Assigns 7-segment display    pins to board */
        {  
        disp_pin[0] = a;
        disp_pin[1] = b;
        disp_pin[2] = c;
        disp_pin[3] = d;
       disp_pin[4] = e;
        disp_pin[5] = f;
        disp_pin[6] = g;
        }
        void display_number(int num)  /* Function for
         displaying number (0-9) */
        {
        switch(num)
        {
        case 0:
        digitalWrite(disp_pin[0], LOW); /* Drive disp_pin[0] to LOW */
        digitalWrite(disp_pin[1], LOW);/* Driving LOW turns on 
        LED segment for common anode display */
        digitalWrite(disp_pin[2], LOW);
        digitalWrite(disp_pin[3], LOW);
        digitalWrite(disp_pin[4], LOW);
        digitalWrite(disp_pin[5], LOW);
        digitalWrite(disp_pin[6], HIGH); 
        break;
        case 1:
        digitalWrite(disp_pin[0], HIGH);  /* Drive disp_pin[7] to HIGH */
        digitalWrite(disp_pin[1], LOW);
        digitalWrite(disp_pin[2], LOW);
        digitalWrite(disp_pin[3], HIGH);  /* Driving HIGH turns off LED
         segment for common anode display */
        digitalWrite(disp_pin[4], HIGH);
        digitalWrite(disp_pin[5], HIGH);
        digitalWrite(disp_pin[6], HIGH);
        break;
        case 2:
        digitalWrite(disp_pin[0], LOW);
        digitalWrite(disp_pin[1], LOW);
        digitalWrite(disp_pin[2], HIGH);
        digitalWrite(disp_pin[3], LOW);
        digitalWrite(disp_pin[4], LOW);
        digitalWrite(disp_pin[5], HIGH);
        digitalWrite(disp_pin[6], LOW);
        break;
        case 3:
        digitalWrite(disp_pin[0], LOW);
        digitalWrite(disp_pin[1], LOW);
        digitalWrite(disp_pin[2], LOW);
        digitalWrite(disp_pin[3], LOW);
        digitalWrite(disp_pin[4], HIGH);
        digitalWrite(disp_pin[5], HIGH);
        digitalWrite(disp_pin[6], LOW);
        break;
        case 4:
        digitalWrite(disp_pin[0], HIGH);
        digitalWrite(disp_pin[1], LOW);
        digitalWrite(disp_pin[2], LOW);
        digitalWrite(disp_pin[3], HIGH);
        digitalWrite(disp_pin[4], HIGH);
        digitalWrite(disp_pin[5], LOW);
        digitalWrite(disp_pin[6], LOW);
        break;
        case 5:
        digitalWrite(disp_pin[0], LOW);
        digitalWrite(disp_pin[1], HIGH);
        digitalWrite(disp_pin[2], LOW);
        digitalWrite(disp_pin[3], LOW);
        digitalWrite(disp_pin[4], HIGH);
        digitalWrite(disp_pin[5], LOW);
        digitalWrite(disp_pin[6], LOW);
        break;
        case 6:
        digitalWrite(disp_pin[0], LOW);
        digitalWrite(disp_pin[1], HIGH);
        digitalWrite(disp_pin[2], LOW);
        digitalWrite(disp_pin[3], LOW);
        digitalWrite(disp_pin[4], LOW);
        digitalWrite(disp_pin[5], LOW);
        digitalWrite(disp_pin[6], LOW);
        break;
        case 7:
        digitalWrite(disp_pin[0], LOW);
        digitalWrite(disp_pin[1], LOW);
        digitalWrite(disp_pin[2], LOW);
        digitalWrite(disp_pin[3], HIGH);
        digitalWrite(disp_pin[4], HIGH);
        digitalWrite(disp_pin[5], HIGH);
        digitalWrite(disp_pin[6], HIGH);
        break;
        case 8:
        digitalWrite(disp_pin[0], LOW);
        digitalWrite(disp_pin[1], LOW);
        digitalWrite(disp_pin[2], LOW);
        digitalWrite(disp_pin[3], LOW);
        digitalWrite(disp_pin[4], LOW);
        digitalWrite(disp_pin[5], LOW);
        digitalWrite(disp_pin[6], LOW);
        break;
        case 9:
        digitalWrite(disp_pin[0], LOW);
        digitalWrite(disp_pin[1], LOW);
        digitalWrite(disp_pin[2], LOW);
        digitalWrite(disp_pin[3], LOW);
        digitalWrite(disp_pin[4], HIGH);
        digitalWrite(disp_pin[5], LOW);
        digitalWrite(disp_pin[6], LOW);
        break;
        default:
        digitalWrite(disp_pin[0], HIGH);
        digitalWrite(disp_pin[1], LOW);
        digitalWrite(disp_pin[2], LOW);
        digitalWrite(disp_pin[3], LOW);
        digitalWrite(disp_pin[4], LOW);
        digitalWrite(disp_pin[5], HIGH);
        digitalWrite(disp_pin[6], LOW);
        break;
        }
        }
        void setup() {
        pinMode(6, OUTPUT); 
        pinMode(7, OUTPUT);
        pinMode(8, OUTPUT);
        pinMode(9, OUTPUT);
        pinMode(10, OUTPUT);
        pinMode(11, OUTPUT);
        pinMode(12, OUTPUT);
        define_segment_pins(12,11,10,9,8,7,6);
        /* a-g segment pins to Arduino */
        }
        void loop() {
        int i;
        for(i = 9; i>=0; i--)
        {
        display_number(i);
        delay(1000);
        }
        for(i = 0; i<=9; i++)
        {
        display_number(i);
        delay(1000);
        }
        }
    
            
            
          

    LED based 7-segment displays are very popular amongst Electronics hobbyists as they are easy to use and easy to understand.

    And has many applications as we discussed above.

    As putting the end of our tutorial, I would like to give a simple exercise you remember we said in the introduction that we can also display alphabets, how about we display some alphabets?