This electronic dice simulator is a replacement for dice and other randomizers in board games. It was designed with two main goals in mind. First, in addition to simulating dice, it should be able to generate random numbers from other distributions not easily realizable by dice or other traditional components. Second, it should be more fun to interact with than a smart phone app. In other words, we wanted to maintain the fun of dice while expanding the possibilities for game designers and players.
Addressing the first goal was fairly simple. Incorporating the Pro Micro microcontroller allows the Fireball to generate a random number based on any distribution which can be coded in Arduino. A simple example of a distribution which is not easily realizable by dice is a uniform random number between 1 and 7 since there is no 7-sided regular polyhedron. A more complicated example would be tweaking the variance of how many times a particular number is rolled. This is useful for games such as The Settlers of Catan, in which the numbers rolled correspond to events or actions rather than numerical values.
This Instructable was made as part of the CS graduate course "Tangible Interactive Computing" at the University of Maryland, College Park taught by Professor Jon Froehlich. Please see http://cmsc838f-s15.wikispaces.com/ for more details. This was a joint project with classmate Elizabeth McNany.
Note: The video erroneously states that the accelerometer seeds the random number generator. While you could program it to do this, the code we provide on GitHub does not. However, the amount and duration of wobbling sensed by the accelerometer determines how many "random" numbers it cycles through before settling on a result. So the "randomness" is still affected by the physical motion of the device.
Step 1: Materials
We used the following materials:
Wires, solder, resistor, tape, copper tape (optional), conductive paint (optional)
Step 2: Find a Wobbly Object and Make Necessary Modifications
Choosing an object:
We chose a clear plastic ornament ball about 4 inches in diameter, but anything roughly spherical or wobbly will work. You could even use something opaque and mount the LED display on the outside. I recommend choosing something that is designed to wobble and come to rest quickly.
We found that the plastic ball was too wobbly and took too long to stop moving as shown in the video. To address this, we sanded down a small flat spot on the bottom of the ball, covered it with gaffer's tape to give it some friction, and added clay to the lower fourth of the ball for weight.
Step 3: Schematic for Reference
The orientation of parts in this schematic is somewhat different from our final product, but the pins are all connected the same way. Please refer back to this schematic if the wiring in the pictures is unclear. I have included some pictures from different angles here as well.
Step 4: Mount the Battery, Add an On/off Switch, and Power the Pro Micro
Mounting the Battery:
We placed the battery in the bottom with the clay since it is one of the heaviest components. Our battery is just taped to the bottom and surrounded by clay, but you could instead mount a plastic battery case to make changing the battery easier. After mounting the battery, check the balance and adjust the clay if the device is tilting to one side. If you get it balanced in this step, you will only need to make minor adjustments later.
Adding an on/off switch:
We designed our ball to turn on when the top is snapped on in the correct orientation. As shown in the left side of the picture, the positive wire leaving the battery terminates at a piece of copper tape on the edge of the bottom half of the ball. The positive wire leading to the Pro Micro does the same. A third strip of copper tape along the edge of the top half of the ball connects these two wires when the ball is snapped together.
Connecting the battery to the Pro Micro:
The positive charge should go to the pin marked "RAW" and the negative charge should go to one of the pins marked "GND" (ground).
Step 5: Install the "button"
This button will allow you to cycle through different modes, such as different numbers of dice being simulated. We didn't want a bulky button, so we simply have two wires poking out of the side of the ball and the users finger completes the circuit. We were hesitant to try drilling through the brittle plastic so we used a soldering iron to heat the tips of the wires, then pressed them through the plastic.
We connected this to input pin "A0". Make sure you add a pull-up or pull-down resistor as shown in the picture. Depending on the resistor you use and how far apart the wires are, you will need to adjust the threshold in the Arduino code for what reads as a button press.
Step 6: Add the Accelerometer
Add the accelerometer to the breadboard and connect the pins as shown: "SCL" to "SCL" (pin 3 on Pro Micro) and "SDA" to "SDA" (pin 2 on Pro Micro). You will also need to connect to "VCC" and "GROUND". If you're using a different microcontroller, check the specs to find out which pins are "SCL" and "SDA". The accelerometer allows us to sense whether or not the ball is wobbling and the speed at which it is wobbling.
Step 7: Add the 7 Segment Display
Add the 7 segment display and connect the pins as shown. Connect "RX" (Serial input) on the display to pin 8 on the Pro Micro. You will also need to connect to "VCC" and "GROUND". This display will cycle through random values from the programmed distribution until the ball settles and stops moving.
Step 8: Upload the Code
The code for this project can be found on GitHub here.
This code simulates rolling dice and lets you choose how many dice to roll (up to 7) using the button. Please comment if you have suggestions for other distributions or specific board games the device could support. One feature I might add is a Settlers of Catan randomizer which alters the variance of the dice rolls (e.g. reducing the probability of going 30 rolls without rolling a 6).