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

Project 6.3: Two-Dice Project

Project 6.3: Two-Dice Project

Project Description

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.


Figure 6.12: Block diagram of the project

Project Hardware

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.


Figure 6.13: Circuit diagram of the project

Project PDL

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...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Air Switches
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.