7 segment display is an old school Opto-Electronic Display device mainly used to display alphabets and digits. As the name suggests, these displays include seven segments that switch ON & OFF to display the required digit or alphabet. The segments in this display are normally single LEDs or liquid crystals. These displays are extensively used in electronic meters, digital clocks, displays in home appliances, basic calculators, cars & different electronic devices that display numerical data. So let us discuss more about a 7-segment display in this article.
What is a 7-segment display?
It is a display in which there are 7 segments, in which each segment or a ‘6 sided box’ consists of two thin pieces of metal, usually aluminum. The segments are also arranged at a right angle.
The individual numerals of a 7-segment display are made up of light-emitting diodes. The LEDs within each digit are optically combined to appear as one element on the display, which has some reflective coating on the inside of each segment.
These displays are also available in a wide variety of styles from 0.3″ displays up to 3″ or larger displays.
7 Segment Display Pinout
The seven-segment display includes 10 pins where each pin is explained below.
- Pin1 (e): This pin is used to control the left bottom LED of the display
- Pin2 (d): This pin is used to control the bottom-most LED of the display
- Pin3 (Com): This pin is used to connect to Vcc or Ground-based on display type
- Pin4 (c): This pin controls the right bottom LED of the display
- Pin5 (DP): This pin controls the decimal point LED of the display
- Pin6 (b): This pin controls the top right LED of the display
- Pin7 (a): This pin is used to control the topmost LED of the display
- Pin8 (Com): This pin is connected to Vcc/GND based on display type
- Pin9 (f): This pin controls the top left LED of the display
- Pin10 (g): This pin is used to control the middle LED of the display
Types of 7 Segment Display
7 Segment Displays which have 7 LEDs are arranged in a way that can display numbers from 0-9. 7-segment displays are connected to the microcontroller in the same way as LEDs (i.e. in series with a current limiting resistor). The only difference is that they have 8 pins rather than 2 pins because each of the 7 LEDs has its own pin along with a common cathode or anode pin. There are two main types of 7-segment displays:
Please refer to this link for 7-segment Display MCQs
7 Segment Display Common Anode:
In this type, all LEDs share a common anode terminal while each cathode terminal is connected to a different segment. In order for a segment to light up, the corresponding cathode terminal will be grounded and the common anode terminal is provided with +5V source voltage. To interface a common anode type to a microcontroller then the Cathodes of each segment are connected through appropriate port pins of the microcontroller. When we want to turn on any particular segment then we need to apply logic zero on the corresponding cathode.
7 Segment Display Common Cathode:
In this type, all LEDs share a common cathode terminal while each anode terminal is connected to a different segment. In order for a segment to light up, the corresponding anode terminal will be provided with +5V source voltage and the common cathode terminal will be grounded. To interface a common anode type to a microcontroller then the Anodes of each segment are connected through appropriate port pins of the microcontroller. When we want to turn on any particular segment then we need to apply logic high on the corresponding anode.
Other forms of 7-segment display include: A popular variant of the 7 segments LED display is the 4 digits 7 segments LED display. As evident from the name itself, a 4 digit 7 segments LED display consists of 4 seven segment LED displays connected together in such a way that they can display any number between 0000 to 9999 with the help of a counter IC like the CD4033, or a LED driver MAX7219.
The fourteen-segment display has four additional diagonal bars between the top horizontal and middle vertical segments; it was used on some early pocket calculators.
The sixteen-segment display adds four diagonal bars between each set of two adjacent vertical segments; it is used on some calculators and watches.
7-segment Display Working
The truth table of seven segment display is shown below which includes decimal digits from 0 to 9 and individual segments illuminated from a to g.
Decimal Digits |
a |
b |
c |
d |
e |
f |
g |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1 | 0 | 1 | `1 | 0 | 0 | 0 | 0 |
2 | 1 | 0 | 0 | 1 | 1 | 0 | 1 |
3 | 1 | 1 | 1 | 1 | 0 | 0 | 1 |
4 | 0 | 1 | 1 | 0 | 1 | 1 | 1 |
5 | 1 | 0 | 1 | 1 | 0 | 1 | 1 |
6 | 1 | 0 | 1 | 1 | 1 | 1 | 1 |
7 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
8 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
9 | 1 | 1 | 1 | 1 | 0 | 1 | 1 |
The working of the 7-segment display can be done by glowing the necessary individual LEDs within the digit. The display can be controlled through freely left pins. Once these pins are forward biased in a series then it will display the specific alphabet or numeral. Based on the seven-segment type, the segment pins are applied with logic zero or high & in the same method to the common pins also.
Once the power of a 7-segment display is ON then an 8 number will be displayed. If we disconnect the power, particularly for ‘g’ then it will display as ‘0’. For instance, if you want to display numeral ‘1’ then both the segments like b & c need to be switched ON & the remaining segments will be switched off.
7-segment Display Interfacing with Arduino
The circuit of a 7-seg display can be easily implemented by connecting 8 LEDs in a specific pattern as shown in the below figure. You must have noticed that each segment (a, b, c, d, e, f, g) is assigned a letter from A to G. This is done to correctly identify the pattern of connections between them and the input pins of the microcontroller.
Interfacing a seven-segment display with Arduino is shown above. In this circuit, a common anode seven segment display is interfaced to the Arduino UNO board to display 0 to 9 digits within a loop. So the interfacing diagram, required components, code, and its working are discussed below.
The required components of this circuit mainly include Arduino UNO, breadboard, power supply, seven-segment display, 7 220Ω resistors, and connecting wires.
The connections made from 7 segment display pins to Arduino board pins follow as;
- From Pin-a of seven segment display to pin13 of Arduino board.
- From Pin-b of seven segment display to pin12 of Arduino board.
- From Pin-c of seven segment display to pin11 of Arduino board.
- From Pin-d of seven segment display to pin10 of Arduino board.
- From Pin-e of seven segment display to pin9 of Arduino board.
- From Pin-f of seven segment display to pin8 of Arduino board.
- From Pin-g of seven segment display to pin7 of Arduino board.
In this circuit, a common cathode type 7 Segment Display is used. So the common pin can be simply connected to Arduino board Pin 9 & is made HIGH always.
In common cathode type, reverse the logic from LOW with HIGH & HIGH with LOW. Because in this type, LED lits once some +positive voltage is provided to any pin.
Project Code
//Seven segment display with arduino uno
void setup() {
int a = 13; //Arduino pins connected with 7 segment pins
int b = 12;
int c = 11;
int d = 10;
int e = 9;
int f = 8;
int g = 7;
void setup() {
//Declaring all the pins as output
pinMode(a, OUTPUT); pinMode(b, OUTPUT); pinMode(c, OUTPUT);
pinMode(d, OUTPUT); pinMode(e, OUTPUT); pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
digitalWrite(d, HIGH); //Generating 1
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, HIGH);
delay(1000); // wait for a second
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, HIGH); //Generating 2
digitalWrite(d, LOW);
digitalWrite(e, LOW);
digitalWrite(f, HIGH);
digitalWrite(g, LOW);
delay(1000); // wait for a second
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW); //Generating 3
digitalWrite(e, HIGH);
digitalWrite(f, HIGH);
digitalWrite(g, LOW);
delay(1000); // wait for a second
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH); //Generating 4
digitalWrite(f, LOW);
digitalWrite(g, LOW);
delay(1000); // wait for a second
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, HIGH); //Generating 5
digitalWrite(f, LOW);
digitalWrite(g, LOW);
delay(1000); // wait for a second
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
digitalWrite(d, LOW); //Generating 6
digitalWrite(e, LOW);
digitalWrite(f, LOW);
digitalWrite(g, LOW);
delay(1000); // wait for a second
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH); //Generating 7
digitalWrite(f, HIGH);
digitalWrite(g, HIGH);
delay(1000); // wait for a second
digitalWrite(a, LOW );
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW);
digitalWrite(e, LOW); //Generating 8
digitalWrite(f, LOW);
digitalWrite(g, LOW);
delay(1000); // wait for a second
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, HIGH);
digitalWrite(e, HIGH); //Generating 9
digitalWrite(f, LOW);
digitalWrite(g, LOW);
delay(1000); // wait for a second
}
In order to activate a specific segment, for instance, segment ‘a’, the equivalent Arduino Pin should be made High. So, here the segment ‘a’ is simply connected to pin-13 of the Arduino board. In the same way, other segments can also be made High. Based on the above truth table of the seven-segment display, depending on the selected segments, a digit can be simply displayed on the 7 Segment Display.
7-segment display Advantages
7-segment displays have some advantages they are
- Inexpensive and extremely popular and simple structured.
- Since the digits share common cathodes or anodes, they can be driven by a single driver IC (although usually two separate driver ICs are used – one for the cathodes and one for the anodes). The driver ICs can sink or source current from a microcontroller output pin, which makes them easy to interface to microcontrollers in digital systems.
- A large number of LEDs in each digit means that they can be easily read at a distance or in low light.
- Only four signal lines are required to control each digit (one signal line for each segment, plus one signal line to select the digit). This makes them easier to implement.
- It consumes little power, making it appropriate for battery-driven devices such as calculators.
- It is easy to distinguish between numerals and other alphabets or symbols.
7-segment Display Disadvantages
The disadvantages of the seven-segment display are;
- It can display only numerals, HEX values, and some predefined characters. It cannot display other symbols like alphabets, other than the English language characters.
- It has low resolution.
- It is not suitable for the display of decimal points. For the decimal point, a separate extra LED is required.
Applications
The applications of the seven-segment display include the following.
- Seven segment displays are mostly used in electronic meters, digital calculators, clock radios, digital clocks, digital clocks, odometers, etc.
- At present, most of the seven-segment display applications are with LCDs due to low power consumption.
Thus, this is all about an overview of a 7 segment display and it’s working with applications. The interfacing of a seven-segment display with an Arduino is used to display 0 to 9 digits with ease. So these display devices are mainly applicable in bigger electronics projects like Alarm Clocks, object counters, timer circuits, digital clocks, etc. Here is a question for you, what are other different displays used in electronic projects?