9
4.9 7-Segment LED display
The type of the 7-segment LED display on the Alice EduPad is called common anode, all
cathodes are driven individually by an output pin and the anode is connected to the 5V supply.
Before sending a number to a 7-segment LED display, the number must be converted to its
corresponding 7-segment code depending on how the 7-segment display is connected to an
output port.
Because there are not enough I/O pins available, the Alice EduPad incorporates an HCT595
shift register to drive the cathodes. When a cathode is low, the corresponding LED segment
lights up.
By convention, the 7segments are called segment A, B, C, D, E, F and G. Their locations in the
display are shown below:
The segment A, B, C, D, E, F, G and Decimal Point are driven by QA, QB, QC, QD, QE, QF,
QG, and QH, respectively. The hex value of the segment code is shown in the following table:
Number DP G F E D C B A Hex Value
1
0
0
0 0
0
1
1
0
0x06
2
0
1
0 1
1
0
1
1
0x5B
3
0
1
0 0
1
1
1
1
0x4F
4
0
1
1 0
0
1
1
0
0x66
The above table only lists #1 to #4, it’s not difficult to figure out the other numbers once
you know how #1 to #4 are created. To display the number 1 on the 7-segment display,
you normally send 0x06 to the HCT595. Since this has a common anode, you need to
invert the 0x06 before sending data out to the HCT595. You could invert the number and
send 0xF9 to the HCT595 or you could use the C operator and send ~0x06.