The goal of this project is to build a set of six-sided game dice with Curie-powered Arduino 101 boards inside. Each die uses the inertial measurement unit (IMU) that is built into Curie™ to determine the resulting values of the rolls. These results are sent to a game running on the PC via Bluetooth Low-Energy (BLE).
For more fun, each die also has LEDs and a vibrate actuator that provide visual and haptic feedback for motion, roll result, and winner indication.
On the PC, a "server" process communicates to the dice and a game application.
To demonstrate this setup, we have a simple car racing game shown at the Austin Maker Faire 2016. 1 – 4 Players roll their die simultaneously. Their respective race cars move the amount of each roll around the track. The first car that makes one loop around the track and crosses the finish line wins the race.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: What You Need:
- Arduino/Genuino 101 - one per die - Amazon
- PC with built-in BLE, or a BLE usb adaptor - Amazon
- 3.7v lithium batteries - 2 per die - Amazon
- Battery connectors - Amazon
- On/off switch - Amazon (or similar)
- Cube enclosure
- Neopixel Stick with 8 LED Adafruit
If you want haptic feedback on the die (this is optional):
- Vibrating Mini Motor Disc Adafruit
- 2N2222 NPN Transistor
- 1N4001 Diode
- 1K Ohm resistor
- Prototype board to build circuit
- Foam sheets from hobby store for padding
- Glue stick/glue gun
Step 2: Powering the Arduino101 and Dice ID
The 2 batteries fit nicely under the Arduino101. We used some double-sided tape and a rubberband to hold it in place. See details in picture.
On the top side we mounted the power switch. A pin hole is drilled into one face of the die allowing a small screwdriver or paperclip to turn on and off the die.
Each die needs to be set to a unique dice ID. This is done by grounding one of the digital I/O pins as follows:
- DICE ID=0 if no jumpers on pins 10, 11, or 12.
- DICE ID=1 if jumper from GND to pin 12.
- DICE ID=2 if jumper from GND to pin 11.
- DICE ID=3 if jumper from GND to pin 10.
Step 3: LED, Vibrate Motor, and Padding
The NeoPixel and vibrate motor should be securely attached to the inside of the die.
Follow schematics to wire up the NeoPixel and vibrate motor circuit. A shield was made to layout the circuit and wiring.
Step 4: 101 Placement and Power-On Training
Place the Arduino 101 inside the die case close in the middle. Add foam padding as needed so the Arduino 101 fits snugly inside. Also consider any needed padding on the outside for safety.
The orientation of the Arduino 101 does not need to be precise since when you power on the die, you train the die on the six sides. It will use these values for the duration it is powered on.
The training procedure is as follows:
The die will request the user to orient the die with the requested face up (i.e. towards the sky). The face requested is indicated by the number of LEDs lit. For example, when 5 LEDs are lit, you orient the die with the 5 dots facing up.
You have 2.5 seconds to do this for each face. The LEDs will change colors from RED to YELLOW to GREEN. Once it turns GREEN, it will request the next face value starting the color sequence back to RED. This is the time to reorient the die. This continues until all 6 sides are trained.
Tip: The sequence being requested is 5 - 4 - 2 - 3 - 1 - 6. It will request this same sequence every time. This makes it easy based on how our dice faces are arrange. Power on dice with logo & display facing you, upright so top value is 5 which is the first requested face. Then, rotate die counter clockwise with logo continue to face you. That would be 4, 2, 3. Then, logo up is 1. Then, logo down is 6.
If your die values are arranged differently, you can change the sequence to the way you want inside the source code.
Step 5: Software
The source is at: https://github.com/jkmathes/amf-dice. Git clone or download zip and install to a directory on the PC.
- Install Arduino IDE
- Compile and program CurieDice.ino to your Arduino 101 board.
PC (server app):
- Install Node.js and npm to run the server.
- > cd games/serve
- > npm install
- > node index.js
PC (game app):
The example source code for the racing game is in the games/racing directory. It is possible to build it. However, the game resources are not available at this time. The source code can be used as a template to create other games, or can show how the communication to the server app works.