Interfacing Seven Segment with 8051 Revision as of 10:16, 2 September 2016 by Explorer
In the earlier tutorials, we saw how to interface the LEDs to PIC microcontroller and wrote the code to blink them. However, the LEDs cannot be used to display any user information like numbers, chars etc. To display numeric values we can use seven segment displays. First, we will interface a seven segment to 8051 and display a single digit decimal counter(0-9).
Later same will be extended to multiplex 4 seven segment displays to generate a 4-digit counter.
Seven Segment Display
Well, the name 7 segments imply there are 7 LED segments arranged as shown in figure 1. After LEDs, these are the easiest interfaces to a microcontroller. There is also a decimal point or dp. It is used when decimal digits like 5.1 etc are displayed.
Seven segments are widely used in applications where digits[0-9] are required to be displayed.Although they also display letters A to F as shown in figure(2) simulation. This is a very simple and convenient way to display numbers in a bright fashion.
- Sizes:They come in various sizes; 0.28”, 0.3”, 0.32”, 0.36”, 0.39”, 0.4”, 0.5”, 0.56”, 0.6”, 0.8”, 1.0”, 1.2”, 1.5”, 1.8”, 2.0”, 2.3”, 3.0”, 4.0”, 5.0”, 7.0”)
- Colors: and varied colors too; Red, Green, Yellow, Orange, Blue, and White.
Since these are basically LEDs arranged as a group they can either have the anode in common or cathode thus they are named as Common-Anode/Common-Cathode displays.
- Common Cathode: In this type of segments all the cathode terminals are made common and tied to GND. Thus the segments a to g needs a logic High signal(5v) in order to glow.
- Common Anode: In this type of segments all the anodes terminals are made common and tied to VCC(5v). Thus the segments a to g needs a logic LOW signal(GND) in order to glow.
Below table shows the binary/hex values for displaying the digits on CommonAnode seven segment display.
Below image shows the hardware connection as per the table.
Code: Single Segment
Below is the sample code to display single digit up counter.
Code: Four Segments
Below is the sample code for multiplexing four segments to display 4-digit up counter.
Download the sample code and design files from this link.
Have an opinion, suggestion , question or feedback about the article let it out here!