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 ads by
Signing UpStep 1What 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.
| « Previous Step | Download PDFView All Steps | Next Step » |
















































That was a cool solution to a problem I would have solved in software!
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
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.
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
The easy way, is to take advantage of the fact that the micro can count very very fast, while an external event is occurring, set up a loop where you count between 1 and 27, while monitoring an input - when the input changes, bail out of the loop and use the last number counted to as the 'random' number.
You are very welcome to start on a skeleton program, and I can provide some guidance for you.
Doug
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.
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
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!
I will fix the schematic, incorporating your changes. Thanks for highlighting them.
Doug
Jman
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!!
Broklynlord responded correctly beofre I could get to it.
I hope his response is helpful (The picture at the end of this comment thread)
Doug
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.
Your assessment is almost correct - the code never rolls numbers that end up on illegal combinations.
Doug
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!!
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....
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.
The minimal voltage of 2 LEDs added together is more than the voltage that the PIC pin supports. What should i do?
there are 2 solutions:
1. Use a driver transistor and a higher voltage supply - that may be overkill.
2. Parallel the LED/resistor combinations off the one pin. As long as you are not drawing greater than 50mA, everything will be ok.
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
Ground is -5V correct?
I didnt really understand that at first.......
thanks anyways