A project log for esp8266 Futuristic Hex Wall

A series of 3d printed hexagonal panels outfitted with a number of 24-bit neopixel LEDs provide the backdrop to my invention room.

josh-coleJosh Cole 03/17/2019 at 19:040 Comments

I began thinking about how I would make the hexagons change in-time to music. I quickly realized that in an ideal world, I would be able to generate a script which - if executed at the correct time - would apply time-based effects to hexagon units which synchronize with whatever song is currently playing.

In order to prove this concept, I prototyped "hcode". Which, yes, is very very loosely based on "gcode" (the script for controlling 3d printers and cnc machines). I say very loosely because hcode only has 4 commands and pretty much has zero crossover with gcode except at the highest of levels. But the one takeaway from gcode which inspired this whole thing is the concept of interpolating variables over time. That is exactly what I need to do, just instead of controlling motors I'll be controlling the color of an LED strand.

Here's how it works...

There are two types of commands. Instantaneous and temporal. Each line in a script starts by identifying the specific subroutine and then specifying the hexagon index it will apply to. Lastly, you can specify the parameters needed for whatever routine you are invoking. 

For each hexagon, the list of commands which impact it are collected - in order - and the "start time offset" is computed based on the duration for temporal commands. In this way, the interpreter can "play" the script and know exactly which command it should be at, for any given point in time.

Here's the table of supported commands:

H00Turn hexagon on/off{index} {truthy value}
H01Delay{index} {milliseconds}
H21Transpose RGB over time{index} {target R} {target G} {target B} {duration}
H22Set RGB{index} {R} {G} {B}

So an example of making the first hexagon blink red 3 times.

H21 0 255 0 0 500
H21 0 0 0 0 500 
H21 0 255 0 0 500
H21 0 0 0 0 500 
H21 0 255 0 0 500
H21 0 0 0 0 500 

It's quite verbose, but it also works really well for generating effects.

The challenge with this design

Two major things make this a bit of a headache. The first is that the NodeMCU controller which I am using does not have a lot of memory. So generating an hcode of sufficient size is impossible. Some solutions to get around that - chunk the file and apply it a few commands at a time. Or... use a raspberry pi :-P

Another challenge I ran into is that analyzing the beat pattern for music is actually incredibly, frustratingly complicated. I'm still researching the best way to achieve this part of the system.

But overall, hcode seems to work great. I wrote a little prototyping website where I can test out hcode and see what it would theoretically look like IRL.