top of page
Writer's picturejugaad club

Session 4 : Seven Segment Displays

Updated: Jun 3, 2021



Definition


Seven segment displays are the output display device that provide a way to display information in the form of image or text or decimal numbers which is an alternative to the more complex dot matrix displays. It is widely used in digital clocks, basic calculators, electronic meters, and other electronic devices that display numerical information. It consists of seven segments of light emitting diodes (LEDs) which is assembled like numerical 8.


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.

Each one of the seven LEDs in the display is given a positional segment with one of its connection pins being brought straight out of the rectangular plastic package. These individually LED pins are labelled from a through to g representing each individual LED. The other LED pins are connected together and wired to form a common pin.

So by forward biasing the appropriate pins of the LED segments in a particular order, some segments will be light and others will be dark allowing the desired character pattern of the number to be generated on the display. This then allows us to display each of the ten decimal digits 0 through to 9 on the same 7-segment display.

The displays common pin is generally used to identify which type of 7-segment display it is. As each LED has two connecting pins, one called the “Anode” and the other called the “Cathode”, there are therefore two types of LED 7-segment display called: Common Cathode (CC) and Common Anode (CA).




TYPES OF 7 SEGMENT DISPLAY

1. The Common Cathode (CC) – In the common cathode display, all the cathode connections of the LED segments are joined together to logic “0” or ground. The individual segments are illuminated by application of a “HIGH”, or logic “1” signal via a current limiting resistor to forward bias the individual Anode terminals (a-g).


Common Cathode 7-segment Display






2. The Common Anode (CA) In the common anode display, all the anode connections of the LED segments are joined together to logic “1”. The individual segments are illuminated by applying a ground, logic “0” or “LOW” signal via a suitable current limiting resistor to the Cathode of the particular segment (a-g).

Common Anode 7-segment Display







Working of Seven Segment Displays:

The number 8 is displayed when the power is given to all the segments and if you disconnect the power for ‘g’, then it displays number 0. In a seven segment display, power (or voltage) at different pins can be applied at the same time, so we can form combinations of display numerical from 0 to 9. Since seven segment displays can not form alphabet like X and Z, so it can not be used for alphabet and it can be used only for displaying decimal numerical magnitudes. However, seven segment displays can form alphabets A, B, C, D, E, and F, so they can also used for representing hexadecimal digits.


We can produce a truth table for each decimal digit

Therefore, Boolean expressions for each decimal digit which requires respective light emitting diodes (LEDs) are ON or OFF. The number of segments used by digit: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 are 6, 2, 5, 5, 4, 5, 6, 3, 7, and 6 respectively. Seven segment displays must be controlled by other external devices where different types of micro-controllers are useful to communicate with these external devices, like switches, keypads, and memory.




Driving a 7-segment Display


Although a 7-segment display can be thought of as a single display, it is still seven individual LEDs within a single package and as such these LEDs need protection from over current. LEDs produce light only when it is forward biased with the amount of light emitted being proportional to the forward current.

This means then that an LEDs light intensity increases in an approximately linear manner with an increasing current. So this forward current must be controlled and limited to a safe value by an external resistor to prevent damage to the LED segments.

The forward voltage drop across a red LED segment is very low at about 2-to-2.2 volts, (blue and white LEDs can be as high as 3.6 volts) so to illuminate correctly, the LED segments should be connected to a voltage source in excess of this forward voltage value with a series resistance used to limit the forward current to a desirable value.

Typically for a standard red coloured 7-segment display, each LED segment can draw about 15 mA to illuminated correctly, so on a 5 volt digital logic circuit, the value of the current limiting resistor would be about 200Ω (5v – 2v)/15mA, or 220Ω to the nearest higher preferred value.

So to understand how the segments of the display are connected to a 220Ω current limiting resistor consider the circuit below.

In this example, the segments of a common anode display are illuminated using the switches. If switch a is closed, current will flow through the “a” segment of the LED to the current limiting resistor connected to pin a and to 0 volts, making the circuit. Then only segment a will be illuminated. So a LOW condition (switch to ground) is required to activate the LED segments on this common anode display.

But suppose we want the decimal number “4” to illuminate on the display. Then switches b, c, f and g would be closed to light the corresponding LED segments. Likewise for a decimal number “7”, switches a, b, c would be closed. But illuminating 7-segment displays using individual switches is not very practical.

7-segment Displays are usually driven by a special type of integrated circuit (IC) commonly known as a 7-segment decoder/driver, such as the CMOS 4511. This 7-segment display driver which is known as a Binary Coded Decimal or BCD to 7-segment display decoder and driver, is able to illuminate both common anode or common cathode displays. But there are many other single and dual display drivers available such as the very popular TTL 7447.




Applications of Seven Segment Displays:

Common applications of seven segment displays are in:

1. Digital clocks

2. Clock radios

3. Calculators

4. Wrist watchers

5. Speedometers

6. Motor-vehicle odometers

7. Radio frequency indicators




7 Segment Display Interfacing with Arduino






Interfacing Diagram

Fig: Interfacing 7-Segment Display with Arduino UNO


Here, the 7-Segment display is driven directly by Arduino. Resistors need to be connected between the display and the Arduino UNO board. Depending on which number or alphabet is to be displayed, control signals are applied.

Note : We have used common anode display, hence the common pin is connected to 5V. If common cathode display is used, the common pin needs to be connected to ground.

For common anode display, drive pin LOW to turn on corresponding LED segment.

For common cathode display, drive pin HIGH to turn on the corresponding LED segment.




Counting 0 to 9 on 7-segment


Circuit Diagram:


Code:

// Defining pins of seven segment
int E = 13;
int D = 12;
int C = 11;
int DP = 10;
int B = 9;
int A = 8;
int F = 7;
int G = 6;


void zero()  // Function to print 0
{
 digitalWrite(E,LOW);
 digitalWrite(D,LOW);
 digitalWrite(C,LOW);
 digitalWrite(DP,HIGH);
 digitalWrite(B,LOW);
 digitalWrite(A,LOW);
 digitalWrite(F,LOW);
 digitalWrite(G,HIGH);
}

void one()  // Function to print 1
{
 digitalWrite(E,HIGH);
 digitalWrite(D,HIGH);
 digitalWrite(C,LOW);
 digitalWrite(DP,HIGH);
 digitalWrite(B,LOW);
 digitalWrite(A,HIGH);
 digitalWrite(F,HIGH);
 digitalWrite(G,HIGH);
}

void two() // Function to print 2
{
 digitalWrite(E,LOW);
 digitalWrite(D,LOW);
 digitalWrite(C,HIGH);
 digitalWrite(DP,HIGH);
 digitalWrite(B,LOW);
 digitalWrite(A,LOW);
 digitalWrite(F,HIGH);
 digitalWrite(G,LOW);
}

void three() // Function to print 3
{
 digitalWrite(E,HIGH);
 digitalWrite(D,LOW);
 digitalWrite(C,LOW);
 digitalWrite(DP,HIGH);
 digitalWrite(B,LOW);
 digitalWrite(A,LOW);
 digitalWrite(F,HIGH);
 digitalWrite(G,LOW);
}

void four()  // Function to print 4
{
 digitalWrite(E,HIGH);
 digitalWrite(D,HIGH);
 digitalWrite(C,LOW);
 digitalWrite(DP,HIGH);
 digitalWrite(B,LOW);
 digitalWrite(A,HIGH);
 digitalWrite(F,LOW);
 digitalWrite(G,LOW);
}

void five()  // Function to print 5
{
 digitalWrite(E,HIGH);
 digitalWrite(D,LOW);
 digitalWrite(C,LOW);
 digitalWrite(DP,HIGH);
 digitalWrite(B,HIGH);
 digitalWrite(A,LOW);
 digitalWrite(F,LOW);
 digitalWrite(G,LOW);
}

void six()  // Function to print 6
{
 digitalWrite(E,LOW);
 digitalWrite(D,LOW);
 digitalWrite(C,LOW);
 digitalWrite(DP,HIGH);
 digitalWrite(B,HIGH);
 digitalWrite(A,LOW);
 digitalWrite(F,LOW);
 digitalWrite(G,LOW);
}

void seven()  // Function to print 7
{
 digitalWrite(E,HIGH);
 digitalWrite(D,HIGH);
 digitalWrite(C,LOW);
 digitalWrite(DP,HIGH);
 digitalWrite(B,LOW);
 digitalWrite(A,LOW);
 digitalWrite(F,HIGH);
 digitalWrite(G,HIGH);
}

void eight()  // Function to print 8
{
 digitalWrite(E,LOW);
 digitalWrite(D,LOW);
 digitalWrite(C,LOW);
 digitalWrite(DP,HIGH);
 digitalWrite(B,LOW);
 digitalWrite(A,LOW);
 digitalWrite(F,LOW);
 digitalWrite(G,LOW);
}

void nine() // Function to print 9
{
 digitalWrite(E,HIGH);
 digitalWrite(D,HIGH);
 digitalWrite(C,LOW);
 digitalWrite(DP,HIGH);
 digitalWrite(B,LOW);
 digitalWrite(A,LOW);
 digitalWrite(F,LOW);
 digitalWrite(G,LOW);
}


void setup()
{
 pinMode(E, OUTPUT);
 pinMode(D, OUTPUT);
 pinMode(C, OUTPUT);
 pinMode(DP, OUTPUT);
 pinMode(B, OUTPUT);
 pinMode(A, OUTPUT);
 pinMode(F, OUTPUT);
 pinMode(G, OUTPUT);
}

void loop()
{
 zero();  // Called function to print 0
 delay(1000); // Wait for 1 second
 
 one(); // Called function to print 1
 delay(1000); // Wait for 1 second
 
 two();  // Called function to print 2
 delay(1000); // Wait for 1 second
 
 three(); // Called function to print 3
 delay(1000); // Wait for 1 second
 
 four(); // Called function to print 4
 delay(1000); // Wait for 1 second
 
 five();  // Called function to print 5
 delay(1000); // Wait for 1 second
 
 six();  // Called function to print 6
 delay(1000); // Wait for 1 second
 
 seven(); // Called function to print 7
 delay(1000); // Wait for 1 second
 
 eight();  // Called function to print 
 delay(1000); // Wait for 1 second
 
 nine();  // Called function to print 9
 delay(1000);  // Wait for 1 second
}

Result: Numbers from 0 to 9 will be displayed one after the other with 1 second delay on the 7 segment display. It will be displayed infinite times till the program do not stop.





7 Segment Pattern

Circuit Diagram:


Code:

// Defining pins of seven segment
int E = 10;
int D = 9;
int C = 8;
int DP = 13;
int B = 7;
int A = 6;
int F = 11;
int G = 12;

void setup()
{
 pinMode(E, OUTPUT);
 pinMode(D, OUTPUT);
 pinMode(C, OUTPUT);
 pinMode(DP, OUTPUT);
 pinMode(B, OUTPUT);
 pinMode(A, OUTPUT);
 pinMode(F, OUTPUT);
 pinMode(G, OUTPUT);
}

void abcdefg()  // this fuction turns off all the LEDS
{
 digitalWrite(E,HIGH);
 digitalWrite(D,HIGH);
 digitalWrite(C,HIGH);
 digitalWrite(DP,HIGH);
 digitalWrite(B,HIGH);
 digitalWrite(A,HIGH);
 digitalWrite(F,HIGH);
 digitalWrite(G,HIGH);
}

void loop()
{
 int i;
 
 abcdefg();  // this fuction is called so LED starts from initial
 delay(1000); // Wait for 1 second 
 
 for(i=6;i<13;i++) // loop to turn on LED in order
 {
 digitalWrite(i, LOW); 
 delay(1000); // Wait for 1 second
 }
 
 for(i=12; i>5; i--)  // loop to turn off LED in order
 {
 digitalWrite(i, HIGH); 
 delay(1000); // Wait for 1 second
 }
}

Result: The LEDs will glow in a pattern, moving in clockwise direction. After all the LEDs are turned ON, the code will end by turning the LEDs OFF, in the reverse order.



Check out the session on our youtube:


Written By: Sarthak

2nd year EEE

University Institute of Engineering and Technology, Panjab University








89 views0 comments

Recent Posts

See All

Comments


bottom of page