× Full Image
×

Smart Die

As my final project I would like to make a smart playing die. The idea is that thanks to a gyroscope the die will be able to detect which side is facing up. Also each side will have 7 addressable RGB LEDs that will light up in a different color depending on the side facing up.
Inspiration: Pixel die

Parts:


For the microcontroller I decided to use the Seeed Studion XIAO nrf52840 Sense, which is a small microcontroller with a built-in gyroscope and accelerometer. It is also capable of Bluetooth communication, which will allowed me to connect the die to a smartphone app.

First I needed to create the pcb for the die sides. I used KiCad to create the schematic:

Schematic

And then I created the PCB layout. I needed to create two versions of the PCB as I needed to chain them together to make a cube. However, for that you you need to have two designs. One that turns to the left and one that turns to the right.:

PCB Layout PCB Layout

However, I encountered a problem with the PCB design. I needed the footprint for the LEDs so I dowloaded one from the internet. The problem was that the footprint was not made correctly and the the pins were not labeled correctly for the intended use of the LED. The LED is supposed to be soldered upside down through a hole in the PCB so that it shines on the smooth side of the board. The hole was present in the footprint but the creator forgot that the pins will be flippes as the LED has to be upside down. Luckily this wasn't a fatal error. In the end the only problem was that the DIN and DOUT pins were swapped. Also looking back it was probably better this way anyway as the smooth side being inside made the later desing of the inside of the die much easier.

Because I needed to solder 42 LEDs and especially the 42 SMD capacitors, I decided to use our school's soldering laboratory.

PCB Layout

First I put the solder paste on the PCB and then I placed the LEDs and capacitors on the PCB. For the placing I used a vacuum pick and place machine.

PCB Layout PCB Layout PCB Layout PCB Layout

After that I put the PCB into a reflow oven, which melted the solder paste and soldered the components to the PCB.

PCB Layout PCB Layout PCB Layout

The next step was designing the case for the die, soldering the 6 sides together and testing everything out. I used Fusion 360 to create the 3D model of the die. The case is universal for both versions of the PCB. The full design of all the components is at the end of the page.

PCB Layout PCB Layout PCB Layout

After that I needed to design the internal structure of the die. I needed to contain the microcontroller, the battery, the wireless charging module and the battery charger module. I once again used Fusion 360 to create the 3D model. One problem I encountered was that the charging module was outputing a current of 1A, which was too high for the battery. The battery was only rated for 600mAh and with a charging currect of 1C I needed the charging module to output only 0.6A. Luckily I found a solution. I swithched the programming resistor on the module from a 1.2k to a 2k resistor. However at I was already running out of time and I didn't access to a soldering laboratory so I needed to soleder the resistor to the module by hand. Iwas a real pain, but I managed in the end.

All that was left to do was to 3D print the internal structure and put everything together.

PCB Layout PCB Layout PCB Layout

And finaly here is the final product.

Here you can see the full 3D model of the die. It contains the PCB, the internal structure and the case. I highly recommend you to play with it a bit and see how everything fits together using the 'Model browser ()'.


The next step was to program the microcontroller. I used the Arduino IDE to program the microcontroller. I used the Adafruit NeoPixel library to control the LEDs and the Adafruit Sensor library to read the gyroscope data. I also used the Bluefruit library to communicate with the Android app. The app is able to send a simple string to the microcontroller, which is then displayed on a serial monitor. The app is also able to send a complex animation to the microcontroller. The animation is a serialized class object using Cbor, a library for encoding and decoding data in a compact binary format.

If you want to see the code for the Android app, you can find it on my GitHub: Smart Die App