Gravity Cube: an LED cube full of liquid light

A cube of 512 LEDs with a little lake of light inside it.

Tilt the Gravity Cube and the light runs downhill. Shake it and it sloshes against the walls. Spin it and it swirls the other way and climbs the sides. Double-tap it and the whole thing takes on a new colour.

It's an 8×8×8 LED cube: six 8×8 WS2812 panels, 384 LEDs in one chain, driven by a thumb-sized ESP32-S3 SuperMini with a BMI160 motion sensor on top. The idea isn't new. What I wanted was for the "liquid" to behave like an actual liquid rather than a pile of pixels sliding into a corner.

Real fluid physics, on a microcontroller

So the cube runs a proper fluid simulation. It's a FLIP solver: 512 particles carry the fluid's velocity around, a grid with one cell per LED keeps the flow incompressible, and each step the particles feel gravity plus the forces you get from holding a turning box (the ones that make your coffee swirl when you spin the mug). A light switches on where enough particles gather and off again only once they have clearly left, so a settled surface lies still instead of flickering.

One physics step takes about 17 ms on the ESP32-S3, which gives 55 frames a second. One core does the physics while the other pushes the previous frame out to the LEDs, so neither waits for the other.

How it works (for the technically curious)

Building it

Six panels on six faces leave many ways to put one on the wrong face or upside down. So the firmware has an assembly mode: each panel lights its centre in its own colour and each edge in the colour of its neighbour. On a correctly built cube every seam shows two matching strips, and a mistake is easy to spot.

The enclosure, called Voxel Skin, is a translucent resin cube printed as an open box with a lid. Inside, a grid of thin baffles keeps each LED's light in its own square, so the surface reads as voxels rather than blur. The same generator builds two sizes, for rigid 65 mm panels and for flexible 80 mm ones, and you can turn both around in a 3D viewer.

The Voxel Skin enclosure in the 3D viewer, lid open
The Voxel Skin enclosure in the 3D viewer, lid open

The physics started life in Rust, in gravity-cube-rs. This version ports the solver to C on ESP-IDF 6.1.

👉 Firmware, wiring, enclosure and tests: https://github.com/psytraxx/gravity-cube-espidf

Preview
Gravity Cube: an LED cube full of liquid light