Light-Up Dice (Random Number Chooser)
by cadefuhriman in Circuits > Microcontrollers
304 Views, 1 Favorites, 0 Comments
Light-Up Dice (Random Number Chooser)
I created a dice that lights up when a number is chosen. I created this because I wanted a dice that won't roll to far away from me or roll off of the table. Instead, it can stay in the same place where everyone playing a game can see it and reach it. The device uses the Circuit Playground Express to generate a random number, 1-6, and then display the corresponding number of lights on the top.
Supplies
To create this device, I used:
- The Adafruit Circuit Playground Express
- Conductive Thread
- Thread
- Six LED lights
- Six square pieces of felt cut to be the same size
- Cotton
- Scissors
Coding the Circuit Playground
First, the Circuit Playground needs to be coded to randomly generate a number, 1-6, and then send the command to light up the corresponding amount of lights. As seen in the photos, all you need is one block of code. Select a purple input block and set it to "on shake." Now you are going to use six if/else statements in this block. If "pick random number 1 - 6" = 1, digital write the corresponding pin to high. Although the circuit playground will be inside of the dice in the end, I would recommend coding it so that the lights on the circuit playground light up. This way, you can ensure that the code is working correctly. Code the Circuit Playground so that each number will result in the correct amount of lights being lit up. The LED lights will eventually be threaded so that there is a group of 3 lights, 2 lights, and one light, equaling six total lights.
Build the Dice
The wiring of the thread will look something like the drawing here. Be sure to leave at least one side of the dice open until the device is fully coded and threaded correctly. Use the normal thread to sew five or six pieces of felt together to create a cube, leaving one side open.
Attach the Circuit Playground and LED Lights
Securely sew the Circuit Playground into the bottom of the dice. Then, use the conductive thread to attach the LED lights to the top of the dice, while connecting them to the circuit playground. Be sure that the LED lights are attached to the same pins that are specified in your code, otherwise they won't light up. Be careful not to let the conductive thread cross over any other lines of conductive thread. Wire the chosen pin to the positive side of the LEDs, and wire the negative side of the LEDs to a "ground" on the circuit playground. Make sure that a lone LED is connected in a proper circuit to "Pin 1," two LEDs are connected in a proper circuit to "Pin 2," and three LEDs are connected in a proper circuit to "Pin 3."
Finishing Touches
If the code is correct, and the conductive thread is threaded the right way, you should have a working dice! If you shake the dice, it should generate a random number, and that same number of lights should light up on the top! Stuff the cube with cotton so that the battery pack doesn't shake around, and sew the sixth and final side onto the dice. You can add decorative circles onto the device to mask any exposed thread, and to give the project the look of a dice!