Microcontroller Intermediate
Kit - Using a 7 Segment LED Display with a 2051
The 7
segment display is found in many displays such
as microwaves or fancy toaster ovens and
occasionally in non cooking devices. It is just
7 LEDs that have been combined into one case to
make a convenient device for displaying numbers
and some letters. The display is shown on the
left. The pinout of the display is on the right.
This version is a common anode
version. That means that the positive leg of
each LED is connected to a common point which is
pin 3 in this case. Each LED has a negative leg
that is connected to one of the pins of the
device. To make it work you need to connect pin
3 to 5 volts. Then to make each segment light
up, connect the ground pin for that led to
ground. A resistor is required to limit the
current. Rather than using a resistor from each
LED to ground, you can just use one resistor
from Vcc to pin 3 to limit the current.
The following table shows how to
form the numbers 0 to 9 and the letters A, b, C,
d, E, and F.
'0' means that pin is connected to ground. '1'
means that pin is connected to Vcc.
a (Pin 1)
b (Pin 10)
c (Pin 8)
d (Pin 6)
e (Pin 5)
f (Pin 2)
g (Pin 9)
0
0
0
0
0
0
0
1
1
1
0
0
1
1
1
1
2
0
0
1
0
0
1
0
3
0
0
0
0
1
1
0
4
1
0
0
1
1
0
0
5
0
1
0
0
1
0
0
6
0
1
0
0
0
0
0
7
0
0
0
1
1
1
1
8
0
0
0
0
0
0
0
9
0
0
0
1
1
0
0
A
0
0
0
1
0
0
0
b
1
1
0
0
0
0
0
C
0
1
1
0
0
0
1
d
1
0
0
0
0
1
0
E
0
1
1
0
0
0
0
F
0
1
1
1
0
0
0
Now, we want to run the display
with the 2051 microcontroller. We will use Port
1 to run the display. Use the same
configuration as in the first 2051 tutorial.
Connect the 2051 to the 7 segment display as
follows.
2051 pin 12 to display pin 9
(P1.0 will control segment g)
2051 pin 13 to display pin 2 (P1.1 will
control segment f)
2051 pin 14 to display pin 5 (P1.2 will
control segment e)
2051 pin 15 to display pin 6 (P1.3 will control
segment d)
2051 pin 16 to display pin 8 (P1.4 will
control segment c)
2051 pin 17 to display pin 10 (P1.5 will
control segment b)
2051 pin 18 to display pin 1 (P1.6 will
control segment a)
Connect the display pin 3 to 5
volts using a 100 ohm resistor.
A sample program that cycles
through the numbers and letters above is
7seg.asm. It is included on the CD that comes
with the Microcontroller Beginner Kit.
Compile the program using TASM
and load the hex file into the 2051. Put the
2051 into the circuit and connect the power.