Electronic Dice Replaces Human Influence

ChipKIT Powered Electronic Dice

[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.

https://www.youtube.com/watch?v=Y3jnwRO5Rt4

44 thoughts on “Electronic Dice Replaces Human Influence

    1. 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.

      1. 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.

        1. 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.

        2. 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.

  1. 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.

  2. 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!

    1. 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?

    2. 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.

  3. 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.

  4. Awesome build!

    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.

  5. 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.

      1. 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.

  6. 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.

Leave a Reply to TruiCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.