Electronic Dice

Dice Banner
This was actually one of my assignments and it’s a pretty simple project with a couple of LEDs to make an electronic dice.

When turned on, all the LEDs will light up and the user have to press and hold on the button to roll the dice. Once the user lets go of the button, the rolling will stop and the dice pattern will be displayed. The LEDs will light up in the same pattern as a traditional dice for easy reading.

Here is how it’s connected :

And here’s the assembly code (for curious ones, I edited the asm file using Notepad++).

Before uploading it into the hardware, I was required to perform a software simulation first to show that the code is correct and functional.
Here is a video of the simulation :

And as expected, it works flawlessly, so here it is in the actual PIC16F84A :


Apparently rolling a dice is hard work, now we can just push a button 🙂

  1. Guro: det er selvsagt lov å være uenig. Samtidig ser jeg at din situasjon er litt spesiell- jeg har desverre ikke satt meg inn ireglene rundt din situasjon.

  2. Rusty Mathis04-26-2014

    Awsome project ! I understand all of the asm code except the $-1, goto $-5, goto $-9 and the decfsz d3,d2.d1 commands. If you have time could you explain how they affect the program ? I am trying a dice project for my final in class and my code is very similiar.

    • Rusty Mathis04-26-2014

      … your code works … mine still needs work. Maybe the previously mentioned commands are the key ?

      • Wai Hung04-27-2014

        Hi. Those commands are for the delay function.
        Goto $-5 means step backwards 5 steps. Decfsz is to decrease a pointer value if it’s not zero.
        These commands combine to give a delay for the denouncing method.

        Microcontrollers run very fast, too fast in fact for human interaction. Therefore delays are used to purposely slow down the MCU.

Leave a Reply