Книга: Advanced PIC Microcontroller Projects in C
Project Hardware
Project Hardware
The circuit diagram of the project is shown in Figure 6.25. A PIC18F452 type microcontroller is used with a 4MHz resonator. Segments a to g of the display are connected to PORTC of the microcontroller through 290-ohm current limiting resistors. Before driving the display, we have to know the relationship between the numbers to be displayed and the corresponding segments to be turned ON, and this is shown in Table 6.8. For example, to display number 3 we have to send the hexadecimal number 0x4F to PORTC, which turns ON segments a,b,c,d, and g. Similarly, to display number 9 we have to send the hexadecimal number 0x6F to PORTC which turns ON segments a,b,c,d,f, and g.
Figure 6.25: Circuit diagram of the project
Table 6.8: Displayed number and data sent to PORTC
Number | x | g | f | e | d | c | b | a | PORTC Data |
---|---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0x3F |
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 |
5 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 0x6D |
6 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0x7D |
7 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 0x07 |
8 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0x7F |
9 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 0x6F |
x is not used, taken as 0.