Image may be NSFW. Clik here to view. ![]() |
7 Segment Interface with 8051 Microcontroller |
7 Segments are commonly used display devices which is capable of displaying numbers and some alphabets. It is more common in Embedded design applications where we needs to display some count or increment numerical values. This tutorial is focused to teach the interfacing of 7 segments with your 8051 microcontroller and how to program it to display numerical or characters.
TYPES OF 7 SEGMENT:
Image may be NSFW. Clik here to view. ![]() |
Common anode and Common cathode Display |
There are two types of 7 segment one is Common Cathode and another one is common Anode. Both of them vary with their mode of connections and programming. As we all know that 7 segment is made of series of LED's aligned together to perform the function of display.
Image may be NSFW. Clik here to view. ![]() |
Connection configuration of 7 segments |
There is one common difference between these two segments, that is they both differ in power sourcing of LED's in it. Common Anode segments are draw current directly from the power source using the Vcc pin and sink it using Microcontroller pins. But Common Cathode LED's are sourced by pins of the microcontroller and sink by means of GND pin.
DISPLAYING NUMERICALS OR CHARACTERS IN 7 SEGMENT:
Image may be NSFW. Clik here to view. ![]() |
Digit formation in 7 Segment |
In 7 segment the display of digits is done by means of turning on or turning off the LED's in respective places. For example if we need to display the digit '0' we need to enable LED's "a,b,c,d,e,f" , that is applying logic 1 or sourcing from microcontroller in case of Common cathode and applying logic 0 or sinking through pins in case of common anode. So for connecting 7 segment from P2.0 to a .........P2.7 to dp of 7 segment our hex code will be
0 - 0011 1111 - 0x3F
1 - 0000 0110 - 0x06
2 - 0101 1011 - 0x5B
Like this we can program to display any digits of our desire by feeding hex code to the ports of the Microcontroller.
CODE:
The below code describes how to display 0 to 9 digits in the 7 segments with some specific time intervals between.
|
NOTE:
- For 7 Segment common anode displays you need to give logic 0 to the LED segments in order to light up.
- Modify the line 12 in the above program as P2=~array[i]; to make it work for common anode segment.
- "~" sign will complement all the values to apply logic 0 at desired pins of the 7 segment.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.![]()
Image may be NSFW.Clik here to view.
Clik here to view.
Clik here to view.
Clik here to view.
Clik here to view.
Clik here to view.