[Will] likes his board games but can’t seem to keep from loosing the dice. He’s been using a dice-rolling smartphone app for a while now and decided that it was time to make a dedicated microcontroller dice roller.
The brain behind the dice roller is a chipKIT uC32 microcontroller. Seven output pins are connected to 7 appropriately-arragned LEDs in the top of the dice. There is only one more electrical component, a momentary switch, that is used to re-roll. When the button is pushed, a random number between 1 and 6 is generated and then displayed via the LEDs in true dice fashion. [Will] wrote his own code for this project and makes it available for anyone to download. The case is 3D printed and was designed in Tinkercad, the files of which are also available. The chipKIT is attached to the 3D printed base by a pair of zUNO clips. Find a short video of this thing in action after the break….
Digging the randomness of the roll but miss the realness of the dice? Check out this real dice roller. Need two electronic dice? Check these.
44 thoughts on “Electronic Dice Replaces Human Influence”
lets evaluate how random those roles really are…..
Sledgehammer, meet walnut…
Sometimes I wonder why this kind of projects are published here on hackaday?
That device is not a hack, neither anything new. It takes just the processors own random number (which isn’t probably “random”) and lights leds.
People should use this for anything %random%: https://code.google.com/p/avr-hardware-random-number-generation/
The rand() function is simple but sufficient for this purpose. The bigger problem may be the random seed. If it is reset to the same value every time the device is reset on, the sequence will be identical.
You don’t even need a rand() function for this. Simply let the controller iterate through all 6 possible numbers as long as the button is pushed. Do that at a high enough frequency (kHz if you want) and it’s fast enough that the random element is the time the button is pushed by the user. For additional fun, when the button is released, you could have the dice ‘roll’ slowly to a halt with the time needed for this taken from the last digits of the system timer that’s running as fast as it can be set.
i came here thinking (like may others) that this is no randomness…but i never though about this method ;)
I would combine the two ideas: while key is pressed, show random number, followed by a short pause. This combines both the rolling animation, and mixes in some entropy.
Combine button bounce, depress length and use the sleep timer (variable length due to RC oscillator) and that’ll be ‘good enough’ for most people.
Sounds more complicated than just calling rand(), which is also good enough.
reminds me of the first solder project they gave us in tech school. An electronic dice roller.
Rolled the exact same sequence every tine. 2,1,3,4,6,5. Didn’t matter how long you held the button. What is sad is there were a number of individuals in my class and others who did not notice the sequence repeated. Checked about 30 kits, all the same sequence.
so a couple of us cut out the button, put a rotary switch in that would freewheel. Spinning it gave us a sorta-random number of pulses.
things got stupid from there. the random spinner became the controller for an AM radio. where the spinner stopped, the signal would send a pulse each time the signal went over a preset threshold for roughly 1 second. Then we tried to randomize the threshold. Then the time. We ended up with a device roughly the size of a 386 desktop PC that could only roll a D6.
We learned a valuable lesson about project scope creep that quarter.
That’s how pretty much every LED-dice kit and magazine article plans do it. Cycle the numbers really fast and stop when the button’s pressed. You don’t need a processor, just a counter and a few diodes to decode the display.
Lots of over-engineering potential
come on, which self-respecting nerd would create such a contraption to only roll d6s? ;)
at least give it the option to go to d20
These dice go to 11.
You’re assuming you’re supposed to count the pips. Jokes on you: binary. :V
That is a big dev board for so few LEDs. As much as I love my Arduinos, I would have gone with a ATtiny inside the cube.
Also: Weird button placement. You could replace the huge board with an equaly huge button to make it conviently to hit the roll-dice function.
or even cooler enclose it all inside of an tap light style case(kinda like an Easy button from staples), and have giant LEDs shine through the plastic top.
If you already have the dev board, the tools and the experience, it’s an quicker & easier solution than to migrate to an ATtiny.
…and in that case you should know you can do it with a 555 & 4017, or even a 6 pin PIC eg 10F200.
corrections for article – losing not loosing, arranged not arragned.
and for Karl – roll not role.
For [will] move the button or make the whole dice the button so it’s push down to roll. Or, hey, just print some dice if you keep losing them.
corrections for comment – Kyle not Karl
“loosing my dice upon the table” is valid as well… Perhaps this one has enough ambiguity that both spellings can be correct.
I hate seeing “dev boards” used in this fashion. It’s terribly wasteful. Some of you seem to have a hard time grasping that fact. Its like you have unlimited money to throw away. It’s your cash, do with it what you want, but it is a seriously stupid use of resourses you could be using for other things. Throwing money at things is the exact opposite of what “hacks” are supposed to be! This could be done without a micro in just about the same time it took to code the firmware, with true randomness to boot. But noooo, lets do pseudo random on a dev board to light 6 leds… thats real resourceful. If you were going to waste a micro on something this simple, why not an AVR or PIC on its own? Why must we waste an entire development board worth of uneeded USB connectors and support hardware when PICs and AVRs can be stand alone? I simply don’t get it. If you are testing something, sure, go ahead, DEVELOPEMENT is fine, but a single die? this has been done about a million times already in much better implementations of hardware. I get sick of all the “lets re-re-invent the wheel” on arduino (or other dev board) posts. You can buy a kit for this that doesn’t even use a micro, or you can buy a kit that does use a micro. How about some clock kit posts? If only there were more posts about crap thats already been done, over and over again!
Calm down. It’s easy to pop the dev board back out and reuse it for something else.
Happy Friday to you too.
So if I understand your rant, nobody should use hardware intended to save time when creating prototypes to create prototypes because building something without starting from first principles is somehow shameful?
Using pre-made solutions (e.g. arduino framework, development boards, shields) is like eating TV dinner. It is okay in moderation when you are busy, but not good for you in the long term. It is more expensive and make your code bloated. It certainly won’t impress the foodies.
You evidently assign no value to your time.
why not , set 6 leds each side | add motion switch | make it all internal – when thrown it will display the numbers of eyes on each side | even get wilder and add a magnetic charger so that when you ‘jiggle’ the dice you actually power it up to display. that’s how i would do such a thing :) – might get a bit bigger tho but hey.
cheat feature : sequence of shakes makes it always the number you want.
Now I need to build your idea! I love the hidden cheat feature!
This kind of electronic dice can be built with a single 4060 and a few LEDs.
There is one small oversight though… That code will not generate uniformly distributed numbers… I.e. Some numbers are more likely than others.
The reason is the, the range of numbers generated by rand is some number that is (most likely) not divisible by 6 (it’s usually some power of 2). Due to the pigeon hole principle, the slotting of the numbers into the 6 bins will result in some bins having more numbers in them. It’s not by much, and if the random number range is quite large then the effect is small.
With 32 bit rand(), the effect is about 1 in a billion. Not enough to worry about.
I remember building an electronic dice in the 80s. Back then the circuit was much simpler, just 2 TTL (one of them a 7490 if I remember right) chips plus some passive stuff. You can find circuits on the net that do it with a 555 and a 4017.
Why waste a whole dev board with a microcontroller for something a bit of simple logic can handle? A sideeffect is that you learn how to use logic circuits.
And a side effect of using a dev board is that your how to use dev boards. Not everybody cares about logic chips.
Well, the other problem with using a devboard is that they are usually limited, most of the time the controller itself can do a lot more. So sticking to a dev board can actually limit your options compared to building your own board (whether you use a microcontroller or fixed logic)
You don’t need to care about logic chips, but it’s more of the same, limited knowledge limits your options and suddenly the only way to make a LED blink you can imagine is using a microcontroller.
I probably would have used two seven segment displays instead to accommodate my d20 rolls too. Maybe a button to toggle through dice “modes” so I can choose what sided dice I would want to roll.
.. now can I take the rest of the afternoon off to do something useful with my dev board please…
This was my first attempt at e-dice. http://zethus.ca/wp/?p=388
I made this shit 7 years ago as a GCSE project, upgraded it to a 7 segment display and utilised a tilt sensor to replicate shaking the dice….
ISTR a project in a 1970’s electronics magazine that used a 555, had a nice wooden case and “rolled” two D6.
What would really be slick is a dice rolling pad with a USB webcam and a program running on the host to optically recognize the roll of real dice. A die* that reads around the base like a D4 would be tricky to read that way.
The purpose of that would be to input genuinely random rolls into computer games. Make it work then call Hasbro…
If there was such a thing as a chip combining RFID and solid state gyroscope – including its own short range coil, the rolling pad could ID each die and its orientation upon the pad and automatically send the roll numbers to the host system. Probably tricky to balance.
Yet another method could be pairs of electrical contacts by each pip and a very fine grid on the pad that can read how many contact pairs are touching it. Would have to be opposing face for top read dies…
*Die is singular version of Dice. Call a die “dice” and the ghost of Gygax will haunt you.
You got a $35 dev board and all you did was make it blink a bunch of LEDs? I mean, sure, it’s fine for a beginner microcontroller project (I can tell by the code), but not exactly anything to write home about.
Or write on Hackaday about.
I heard that NASA spent millions developing a ‘space die’ in the 60’s that would work in zero gravity.
Please be kind and respectful to help make the comments section excellent. (Comment Policy)