Advanced PIC Microcontroller Projects in C: From USB to RTOS with the PIC18F Series

This project is similar to Project 2, but here a pair of dice are used as in many dice games such as backgammon instead of a single dice.
The circuit shown in Figure 6.8 can be modified by adding another set of seven LEDs for the second dice. For example, the first set of LEDs can be driven from PORTC, the second set from PORTD, and the push-button switch can be connected to RB0 as before. Such a design requires fourteen output ports just for the LEDs. Later on we will see how the LEDs can be combined in order to reduce the input/output requirements. Figure 6.12 shows the block diagram of the project.
The circuit diagram of the project is shown in Figure 6.13. The circuit is basically same as in Figure 6.8, with the addition of another set of LEDs connected to PORTD.
The operation of the project is very similar to that for Project 2. Figure 6.14 shows the PDL for this project. At the beginning of the program the PORTC and PORTD pins are configured as outputs, and bit 0 of PORTB (RB0) is configured as input. The program then executes in a loop continuously and checks the state of the push-button switch. When the switch is pressed, two pseudorandom numbers between 1 and 6 are generated, and these numbers are sent to PORTC...