Below is the link to the C source code for the project. It is compatible with the MPLAB X XC8 compiler only.
As Christmas is now on the horizon, I thought it might be fun to design an electronic dice, to give as presents to your family, or just use whilst playing traditional family games during the holidays.
This dice project has seven LED’s which can display the possible outcomes of rolling the dice…in other words, 1, 2, 3, 4 , 5 or 6. A single button instigates the ‘rolling’ of the dice, as the outer six LED’s rotate to indicate motion. When the button is released, the dice value is displayed on the LEDS’s, flashing at a frequency of 2.5Hz.
Here are a few pic’s of the dice in action:
Here the dice prototype is in reset. All LED’s are off.
Here we have pressed the button and been returned the value of 3 for our roll of the dice.
Now we have pressed the button again and been returned the value of 5.
The LED’s rotate as the button is pressed.
The software is very simple. The rotating LED’s when the button is pressed uses a Timer0 interrupt routine to illuminate the six LED’s on the edge of the dice to indicate the rolling of the dice. When the button is released, the LED’s display the value of your roll of the dice.
Here is the C source code which was compiled using Microchip’s XC8 compiler, targeted at a 16f690 microcontroller. dice-c
For those of you who wish to construct this project, here is the circuit diagram (hand drawn). dice_circuit_diagram
Have fun and Merry Christmas!