Toss The Dice

An electronic dice isn’t something hard to come by in today’s electronically enabled “there’s an app for that” age. However, there is a lot of fun and learning experiences to be had by taking the time to DIY. With this simple project, we make a movement detecting electronic dice that you can show off to your fellow board game enthusiasts.

THE BROAD OVERVIEW
There are many circuits around for building an electronic dice. Many of these, however, use discreet components on a large PCB, and don’t have any smarts to keep the results truly random. Many also just use a simple momentary action switch to activate the circuit.

The idea behind this electronic dice was to create something a little more interactive, both in how it is triggered and in its appearance. A 3D printed enclosure provides a tactile feel. To make it easy to pick-up, the enclosure needs to be compact, which is why there are two PCBs used.

By using a Mercury switch, we are able to trigger the circuit when you lift the dice, which is a lot more interactive than simply pressing a button. An ATtiny microcontroller was chosen because of its tiny size and low power requirements. It also makes it possible to power from a button cell battery to keep space to a minimum.

HOW IT WORKS
The device is very simple. It uses a microcontroller to randomly pick a number between 1 and 6 and then displays the result on an array of 7 LEDs arranged in a dice pattern. As an added feature, rather than using a button, I opted to incorporate a tilt switch, so when the user shakes or otherwise disrupts the dice it triggers a new result. This is done using a Mercury filled switch. When tilted, the liquid ball of mercury comes into contact with the two leads of the device, creating a circuit. This circuit is connected to ground and a pin of the microcontroller with an internal pull-up resistor activated.

Avoid breaking the glass as Mercury is a poison.

RANDOM FUNCTION
In a previous project, I found using the analogue read to seed the random function appeared to favour higher numbers. To counter this, I created a small PCB antenna that will help to pick up the random “noise” on the floating pin, which is needed for the analogue read random seeding to work correctly. This does indeed seem to significantly increase the randomisation of the output.

To confirm this, I created a small program that uses the antenna and the analogue read seed function to record 500 loops of the results and display them to the serial output. From there, I created a histogram to check the spread of the data. This resulted in data that appears as if the result has a high level of randomisation and a fairly even distribution. Therefore, I’m fairly confident to say this device will be as random as one would expect from a dice roll.”

Link

Related Content