3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

An LED Dice using a PIC 16F84 (or 16F88)

An LED Dice using a PIC 16F84 (or 16F88)

This is a re-print of a project that I made a number of years ago - I was trawling the web, and discovered that others had been making it, so I decided to put the detail here on instructables.com - so that others can benefit.

Many Led Dice have been published in various forms over the years, using output methods including a 7 segment display to display the numbers 1 through 6, or having 6 individual LEDs or even having a Die shaped display.

All of these designs have been fairly complex in hardware, typically having at least 2 IC’s, 4 or so transistors, and many resistors and capacitors. Most have also been fairly current hungry, discharging a set of batteries in a short period if the device has been left on.

Using a single chip microprocessor allows us to implement 2 individual dice, using a single IC. In addition to this, we turn a hardware problem into a software problem. We can also add features that have previously not existed before, such as the ability to recall the last roll.



The Project

Before we start designing our Die, we need to decide exactly what it does, and how it does it. In doing this, we reduce the likelihood of ‘specification creep’ interfering with the completion of our project.

The specifications for our project are simple;

We will design an electronic simulation of 2 dice, implemented using LEDs. A single push button will control the rolling of the dice in the following manner;

    • When the button is pushed for a short period (say less that 0.5 sec), the dice turn on, and display the result of the last roll.
    • If the button is pushed for greater than about 0.5 Seconds, both dice are cleared then roll independently, eventually slowing, and stopping after the button is released.
    • In all cases, the result is displayed for 50 seconds, and then the dice turns itself off.

It would be desirable to have no power switch, so we have to minimise current consumption while the project is ‘off’.

 



 
Remove these adsRemove these ads by Signing Up
 

Step 1What does a die pattern look like

What does a die pattern look like

Lets look at a good old-fashioned dice. As we all know, it has 6 sides, and if we analyse the various dot patterns in Figure 1 below, we can see that the following rules apply;

  • Opposing Corner dots (1) and (3) appear simultaneously.
  • Opposing Corner dots (2) and (4) appear simultaneously.
  • Middle dots (5) and (6) appear simultaneously.
  • The Central dot (7) operates independently.
The neat thing that this means is that I can present a single die display using only 4 output pins on the micro.  To display 2 separate dies, I only need 8 pins.
« Previous StepDownload PDFView All StepsNext Step »
49 comments
1-40 of 49next »
Nov 22, 2010. 2:00 PMLord_Vek says:
http://www.youtube.com/watch?v=eZTdLBeS5H4
Feb 5, 2011. 12:31 AMsamarahmikhail says:
very nice....where did you connect the slide switch?
Feb 5, 2011. 4:19 AMsamarahmikhail says:
will it affect the program if i add a slide switch between the two die so that i can be able switch the dice in a single mode?
Feb 5, 2011. 7:37 PMsamarahmikhail says:
thank u so much sir..i will try making this one..^_^
Jan 16, 2011. 6:12 AMmwils says:
Hi,
I made a few modifications to the original code. It no longer forces a 6 or a 4 when the random number generator comes up with a 7 or 0. I did this by having two additional variables that change while the button is held down. One variable gets substituted for the 0 and the other for the 7. I also extended the display time slightly and allow a new roll without having to wait for the display to time out. Use the link below to get the modified code. Cheers

http://dl.dropbox.com/u/13137888/LedDiceMod.zip
Jan 12, 2011. 6:20 PMmwils says:
Hi,
I have a few comments. The schematic calls for a .001 capacitor which would be 1000pf not 100pf, which is stated in the article. I made mine with 1000pf, and it looks like the speed is the same as the video. In addition, the statement about the display staying on for 50 seconds is also incorrect. It stay on for about 3 seconds.
Dec 18, 2010. 7:03 PMhum20005 says:
hi i have been given a project to build a random number generator using pic 16F877 and display the result on lcd display. i have to use random number between 0 and 27.
can any1 help me in the software (assembly language). plz any help ?

i will really apperciate if someone can help me to write a complete program ?

thanks
Nov 22, 2010. 10:15 AMLord_Vek says:
I made it !!! Using a 16f84a and the PCB mentioned above, at http://www.italentshare.com/forum/viewtopic.php?f=15&t=414.

Admire it at :

http://www.youtube.com/my_videos?feature=mhum

I put it into an enclosure and gave it as a gift. Thanks for the instructable, my friend.

Nov 1, 2009. 8:22 AMjman 31 says:
I threw one of these together on my protoboard using a PIC16F628A . I only had seven led's laying around, so I only made one die. Seems to work great. Thanks for the ible.

The only thing is for beginners like myself, you might add pins 5 and 14 to the schematic and add their positive and ground connections just to clarify things.

Jman
Nov 1, 2009. 12:42 PMjman 31 says:
I also hate to be negative, but there are a few small errors in you schematic. You have two R8's and two D7's. Second die should be D8 through D14?

I really appreciate you sharing this with us, so please don't take my comments as criticism, but more as a willingness to help this project.

Thanks!
Nov 2, 2009. 4:00 AMjman 31 says:
Cool man. I did a revised schematic in Eagle for myself so I could etch a PCB. If you want I can post it so you don't have to go through the trouble of redrawing it.

Jman
Jul 25, 2010. 12:23 PMVIP168 says:
h , the cct you've posted is it the same as mention above? or its different.?thanks
Mar 4, 2010. 11:32 PMp amit says:
Feb 20, 2010. 7:12 AMonizuka2 says:
....mmmmhhhmmmmm...... o_O
Feb 5, 2010. 1:17 AMpatito says:
Hi, drj113,

First of all, thank you for this project, it's really awesome!!
But I must say I've got a problem: I've checked everything and I can't find the mistake. Everything is OK, but the dice patterns are not good.
Would you please explain the position of each LED?

Thanks!!
Feb 5, 2010. 10:10 PMbrooklynlord says:
I believe there is something wrong with the code.....

0001 is top left and bottom right: that is good as 2
0010 is top right and bottom left: that is a mirror 2
0100 is top middle and botom middle, which doesn't exist. X
1000 is middle: 1.
0011 is the four corners, that is 4
0101 is top and bottom middle with top left and bottom right, doesn't exist. X
1001 is center, and top left and bottom right: thats a 3
0110 is top and bottom middle with top right and bottom left, doesn't exist. X
1010 is center, and top right and bottom left, thats a mirror 3
1100 is a line from top to bottom with center, doesn't exist. X
0111 is the four corners with the middle ones, thats a 6.
1110 is center, middles, and top right and bottom left, doesn't exist. X
1101 is center, middles, and top left and bottom right, doesn't exits. X
1011 is center with the two diagonals, which is a 5.
1111 is all on, which is a seven but that doesn't exist on a die. X

We have 7 "wrong" combinations with 8 "right" combinations.

Which means that about half of the rolls should be correctly displayed.

And is there a way to modify the "random" rolls? so that they only land on the certain binary numbers?

0001,0010,1000,0011,1001,1010,0111 and 1011 are the "correct" numbers. However, there are 2 twos and 2 threes....
 
A fair one:
0001,1000,0011,1010,0111,1011.

No extra 2s and 3s.
Feb 5, 2010. 10:24 PMbrooklynlord says:
In the picture below, the ones are being controlled by the last binary digit (- - - 1 for on, - - - 0 for off), the twos are being controlled by the second last binary digit (- - 1 - for on, - - 0 - for off), the threes are being controlled by the second binary digit (- 1 - - for on, - 0 - - for off), and the four is being controlled by the first binary digit (1 - - - for on, 0 - - - for off).

Feb 5, 2010. 10:25 PMbrooklynlord says:
Feb 6, 2010. 2:33 AMpatito says:
Thank you all!
Indeed, as I never can stay quiet, I begun to change the LEDs places, and I've found a good combination. If the dice picture (step 1) is 1-2-5-7-6-3-4 from top to bottom, left to right, I've found that if I change places to 1-6-4-7-2-5-3, the patterns are right.
I haven't touched the code, as I presume the random number generation is correct, isn't it?

Thank you again for the instructable, and for the answers!!
Feb 6, 2010. 8:38 AMbrooklynlord says:
That is strange. I think theres a wrong connection in your circuit because if one and two are not the opposite corners, then you won't have a correct number 2.......

Unless number 1 is connected to number 3 in your circuit, it shouldn't display properly.


@ the author

What are the possible combinations in the code? i don't really want to wire things up wrong and have illeagal displays....
Feb 6, 2010. 10:31 AMpatito says:
I noticed the explanation about dice numbers in step 1 is wrong (or I've misunderstood, sorry for my english), because opposing corners dots 1 and 3 do not appear simultaneously, nor 2 and 4. 5 and 6 yes, and 7 also.
The thing is, following the image of the dice, 1 and 4 will appear simultaneously, and 2 and 3. Perhaps this is the clue... Or perhaps, as I said, I misunderstood the directions.
Maybe something passed to me, but I've checked the connections about 10 times.
Dec 26, 2009. 4:22 AMTarkov24 says:
sir can you post the complete list of materials for this one?
 
Nov 19, 2009. 9:34 PMbrooklynlord says:
I kinda have a problem....

The minimal voltage of 2 LEDs added together is more than the voltage that the PIC pin supports. What should i do?
Nov 21, 2009. 8:21 AMbrooklynlord says:
The LEDs im using are superbright ones. Is this the problem?

The red on draws 3.1-3.8 v 20-30 mA
The green on draws 2.8-3.2 v 20-30 mA


Also, can you draw a schematic in parraleling on 1 pin? it doesnt have to be fancy, i draw mine with MS paint.

Thanks
Nov 13, 2009. 6:04 PMjman 31 says:
I've done an Eagle  PCB, Schematic and an etchable pdf for this project on my DIY website. You are more than welcome to check it out here. You will have to register to view the files.
Nov 6, 2009. 3:02 PMbrooklynlord says:
uhh.... the schematic doesn't have a 5V -? please add that in?
Nov 12, 2009. 12:40 PMjman 31 says:
Take a look at the link I posted about 5 or 6 posts down. I uploaded a schematic with those connections on it.
Nov 12, 2009. 4:05 PMbrooklynlord says:
thanks
Nov 12, 2009. 6:46 PMbrooklynlord says:
Oh i get it:

Ground is -5V correct?

I didnt really understand that at first.......

thanks anyways
Nov 6, 2009. 7:17 PMbrooklynlord says:
Also, do the capacitors have to be polarized?
1-40 of 49next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
361
Followers
11
Author:drj113
I have a background in digital electronics, and am very interested in computers. I love things that blink, and am in awe of the physics associated with making blue LEDs.