Hardware Reference
In-Depth Information
Example 5.9
Write a program to display the following patterns from the seven-segment display circuit
shown in Figure 4.18 from display #0 to #5 and repeat with each pattern lasting for 600 ms:
123456
234567
345678
456789
567890
678901
789012
890123
901234
012345
Solution: Since there are 10 different segment pattern sequences and two adjacent sequences are
offset by 1, we can overlap these 10 sequences as shown in Figure 5.2.
1
2
3
4
5
67890
1
2
3
4
5
Figure 5.2 Seven-segment display patterns overlapped
Figure 5.1 gives an idea how to produce such a display pattern.
Let SegPat , i , j , and k represent the segment pattern array, the start index of the pattern ar-
ray for the sequence in effect, the number of times remaining for the current display sequence
to be repeated, and the display to be lighted, respectively.
The algorithm of the program is as follows:
Step 1
i
0;
Step 2
j
0
Step 3
k
0
Step 4
Output SegPat[i1k] to Port B, and turn on seven-segment display #k.
Step 5
Wait for 1 ms; k
k 1 1;
 
Search WWH ::




Custom Search