Introduction: Six Sided PCB LED Dice With WIFI & Gyroscope - PIKOCUBE

About: Hey! I'm a maker and an electrical engineering student from germany

Hello makers, it's maker moekoe!

Today I wanna show you how to build a real LED dice based on six PCBs and 54 LEDs in total. Next to its inner gyroscopic sensor which can detect movement and dice position, the cube comes with an ESP8285-01F which is the smallest WiFi MCU I know so far. The MCU dimensions are just 10 by 12 millimeters. Every single PCB has dimensions of 25 by 25 millimeters and contains nine WS2812-2020 mini LED pixel. Next to the controller there is a 150mAh Lipo battery and a charging circuit inside the dice. But more on this later...

If you are searching for an even smaller cube, then check out the first version which I have created on my website. It is casted in epoxy resin!

Pikocube version 1

Step 1: Get Inspired!

Enjoy the video!

You will find nearly everything for the cube in this video. For some further informations, design, PCB and code files you can check out the following steps.

Step 2: PCB Design!

As you might know, my favorite PCB design software is Autodesk EAGLE. That's why I have used it for this project as well.

I've started using two different PCB designs, because I don't want to make the cube bigger than it has to. The outer shapes of both PCBs are just squares of 25x25 millimeters. The special thing of these PCBs are the three castellated holes on each side which distribute the three signals +5V, GND and the LED signal all over the cube. The order of the PCBs is shown in one of the schematics above. Hope you can imagine, the colored sides belong together once the cube is folded as a cube. The arrows are marking the WS2812 signal line.

The schematics, boards and the BOMs of both PCBs are attached to this step.

Step 3: PCBs and Components!

The whole cube consists out of two different types of PCBs. The first one comes with the charging circuit and the Lipo battery jack and the second one contains the MCU, the sensor and some power latching circuit. Of course the PCBs have only be equipped once each. All the rest just containing the nine LEDs on the outside of the cube.

The PCBs special thing are the castellated holes on every side. On the one hand these holes/solder pads are used to get the cube looking like a cube and holding everything in place and on the other hand it transmits both the power for the LEDs and the WS2812 signal. Latter is more complicated because it has to be in a specific order. Every PCB has exactly one input and one output signal only and in order to interrupt one signal at a point, I added a few SMD soldering jumper pads.

Parts you will need for the MCU board:

Parts you will need for the power board:

Step 4: Assembling the Cube!

For all the details of assembling the cube you should refer to the video above.

Assembling the cube isn't the easiest part, but for making it a bit more easy I have designed a small soldering aid where at least three of the six PCBs can be soldered together. Doing it two times you will get two PCB edges which have to be connected once everything is working. Yes, make sure everything is doing. I haven't test it so far, but unsoldering one PCB out of the cube could be difficult.

Make sure to solder three PCBs together before you attach the battery jack. Otherwise you have to modify the .stl file with a small hole where the jack fits in.

Step 5: Arduino Code!

The cube will start with a disabled WiFi to save some power, which is called modem sleep. Regarding to the ESPs datasheet, the MCU takes only 15mA while in modem sleep, whereas it needs around 70mA in normal mode. Good for battery powered devices like this one. To achieve this you will need the following code part before calling the setup function.

void preinit() {
	ESP8266WiFiClass::preinitWiFiOff();
}

With another button press you can wake up the WiFi by calling the standard WiFi.begin() function or in this case the Blynk.begin() which is the setup call for the APP which I have chosen to control the cube.

Converting some animations to the cube is only a little bit of math. The matrix conversion to a pixel on a specific outer wall is done with this simple helper function:

int get_pixel(int mat, int px, int py) {
	//starting at top left corner
	return (px + py * 3) + mat * 9;
}

Referring to the PCB pixel overview in step 2, the first matrix is the top one, the second is the front facing one, next ones are around the cube going into the right direction and the last matrix is the bottom one.

When using the attached code, you have to edit the WiFi credentials to match your network. For correct use with the Blynk APP, make sure to put both the files (BLYNK.ino and the other one with Blynk in it) into the same folder before opening the sketch. The sketch contains of two different tabs. The other file, which does actually nothing, don't need to be equipped with another tab. It is just for making the cube sleep when the button wasn't pressed. Otherwise the cube won't get into sleep and will draw current all the time.

Step 6: The APP!

As already told, the cube starts with a single button press. But it won't start with the WiFi functionality at all. Another single press while the cube is already on will start WiFi and connects to a predefined network. Aftwards you can use the BlynkAPP to control the cube. Of course you can extend the functionality, there are plenty of possibilities for this thing...

A simple example layout inside the Blynk APP is shown here. It consists of two SLIDER (brightness and animation speed), two STYLED BUTTON (change animation pattern and switching the cube off), one STEP for changing cube mode, an LED for showing which dice side is up and last but not least a GAUGE for showing the battery status. All of these widgets make use of the virtual pins for APP-MCU communication. Something to read the virtual pins via the MCU is to call this function, whereas V1 is referring to the used virtual pin and param.asInt() holds the current value of the pin. The constrain function is just for limiting the incoming values (safety first :D).

BLYNK_WRITE(V1) { 
	//StepH  t = millis();
	current_mode = constrain(param.asInt(), 0, n_modes - 1);
}

To write a virtual pin to the Blynk APP you can use the following function:

int data = getBatteryVoltage();
Blynk.virtualWrite(V2, data);

You will get more info to this inside the Arduino sketch!

Step 7: Have Fun!

Designing and building the cube was a lot of fun for me! Nevertheless I have had some problems with it. First one is that I wanted to use a boost converter circuit inside the first version of the cube to ensure the WS2812 LEDs will run at 5V. Luckily they will run at Lipo voltage of around 3,7V as well, because the boost converter was far too noisy and disturbs the LED signal which results in an unintended blinky cube.

Second huge problem is that I wanted to use wireless charging possibility, even for the second version. Luckily I have added some charging pads which are accessible from the outside of the cube because the inductive power gets disturbed through the GND planes of the PCB and the components. Therefore I have to create a 3D printed charging stand, so that the cube can be put in and some contacts get pressed to the cube.

Hope that you enjoyed reading this instructable and may found a way to build your own cube!

Feel free to check out my Instagram, Website and Youtube channel for more informations about the cube and other awesome projects!

If you have questions or something is missing then please let me know in the comments below!

Have fun creating! :)

PCB Design Challenge

First Prize in the
PCB Design Challenge