This is a just-for-fun project I did in the Digilent MakerSpace. Usually whenever I play board games I use a dice-rolling smartphone app since dice are so easy to lose. I thought I would try making my own hardware version though. It turned out really well and was a lot of fun. In this Instructable I will go over how I designed the circuitry, wrote the code for the microcontroller, made the housing, and put it all together!
I entered this project in several contests on Instructables. If you like this project, please vote for it by clicking the "Vote!" ribbon in the top right corner.
Step 1: Materials
Here's a list of the parts I used for this project.
- chipKIT uC32 Microcontroller and USB cable
- You can also use a lot of other microcontrollers such as the Arduino Uno, or chipKIT Uno32
- 7 green 5mm LEDs
- Push button (approx. 6mm wide)
- 2 zUNO clips to hold the microcontroller board
- You can order some or even 3D print your own zUNO clips for free at the link above.
- 3D printed housing (file below)
- Not everyone has access to a 3D printer, but there are plenty of other options here. A thick card stock or paperboard will work perfectly. Also, if you want a 3D printed version and don't have access to a printer, there are several companies (such as i.materialise, Sculpteo, Ponoko, and Shapeways) that will print a design for you and mail it to you.
- For putting everything together you just need some basic tools: wire cutters, a soldering iron, and some glue (hot glue and super glue both work well).
My 3D print design can be found at this link. From this page you can order a print from one of the companies I mentioned above. Or, if you will be printing it yourself, you can download the file here too. Tinkercad will also allow you to make a copy of the file so you can make your own edits. You can make changes to the design to use a different size of LEDs or a different button. You can also make it bigger and even add text or logos!
Now onto the design. I will start by explaining the circuitry in the next step. After that, I will talk about programming the microcontroller. And last but not least, putting it all together!
Note: If you are going to be printing the housing, I would start that now as you continue through the remaining steps. Then the print will be done when you're ready to put everything together.
Step 2: The Circuit
The circuit for this project is very simple. We just need a power and ground connection to the LEDs and a few wires going to the button. Note: the "power" to the LEDs comes from the microcontroller's Digital I/O pins.
I included a schematic view of the uC32 so you can see how everything will eventually be connected to the board.
Step 3: Programming the Microcontroller
I wrote my code in MPIDE. MPIDE is completely free and can be downloaded here. Note: MPIDE can program just about any microcontroller, including all chipKIT and Arduino boards. If you're using an Arduino board and already have Arduino's IDE that will work just as well too.
If you're brand new to microcontrollers and programming in an IDE, here is a quick tutorial that explains how to install MPIDE and use it to communicate with your board: Intro to MPIDE.
The code I wrote for the microcontroller can be seen below. There are three main portions to this "sketch":
- The roll() function which makes it look as if the die is actually rolling. This is a function I created myself and it is included in the code below.
- Generating a random number between 1 and 6 with the rand() function. (This function is predefined in the stdlib.h header file.)
- And a series of if statements to light up the correct LEDs based on the random value that is generated.
This code can be copied directly from the box below and pasted into your IDE. Then you can upload it directly to your board from there. If you're unsure how to upload the sketch, check out the "Intro to MPIDE" tutorial linked above.
Note: Sorry for the very space-consuming formatting for the code. It used to display in a nice little box that you could scroll through, but Instructables made some changes to their editing interface and I'm not able to do that anymore.
For more detail: 3D Printed Microcontroller Dice Roller
Related projects
Voltage Measurement with A PIC Microcontroller
Voltage Measurement with PIC Microcontroller articulates a methodical framework for facilitating analog voltage measurement using the PIC18F4520, an advanced member of Microchip’s...
Development Boards & KitsUltra-Low Power: Microcontroller Standby Current to 130uA with OPEnS Power Control Board
At the OPEnS Lab, a key focus for our projects is achieving exceptionally long battery life. This was particularly true for the...
Development Boards & KitsAn Integrated Approach to Developing Applications with Microchip PIC Microcontrollers
1. Introduction In our daily lives, a variety of devices such as telephones, household appliances, and cars incorporate "smart" electronics, typically manifested...
Development Boards & KitsMicrocontroller-Driven AC Voltage Control with Soft Start Feature
1. INTRODUCTION PWM-based AC voltage controllers find extensive application in uninterruptible power supplies (UPS) and high-power flexible AC transmission systems. This variable...
Development Boards & KitsPIC Microcontroller-Based IC Tester for Efficient Integrated Circuit Verification
1. INTRODUCTION Within the electronics industry[1], as circuit complexity undergoes a drastic increase and the demand for higher reliability rises, a significant...
Development Boards & Kits · PIC16F887Hands-On Microcontroller Projects: BK300 Development Board Featuring PIC16F887 Chip Lab
1. INTRODUCTION The study of microcontroller systems is experiencing a global surge across various fields within science, engineering, and technology departments of...

