This Spectrum Analyzer Is Built from Lego Bricks and an ESP32
See how element14 Presents' Mark Donners made a creative spectrum analyzer that supports different input types and analog audio filters.
Project overview
All wave forms are actually a combination of one or more frequencies that, through constructive and destructive interference, come together to form a single, more complex wave. Spectrum analyzers are tools which allow us to see what frequencies are in the wave along with their amplitudes, and they are vital in so many different fields, but especially music. Waterfall displays, or those grids of LEDs which light up to signify the bands of frequencies and fall after a delay, are commonly used, and this is exactly what Mark Donners from element14 Presents wanted to build, except this time, it would be made from Lego bricks.
Constructing the Lego frame
The frequency analyzer display enclosure is made from three main parts: the base that contains the PCB and control board, a grid of clear bricks through which the LEDs shine through, and the backing to hide the uglier circuitry in the back. Nearly everything was made from opaque black bricks with the exception of the front plate, and full instructions can be found in Donners' write-up on the element14 Present website.
Designing a schematic
Because this project needed to quickly respond to incoming analog inputs and display the results, most of the work in determining the makeup of frequencies is handled by discrete components. First, the user can select via a switch between either the onboard analog microphone element or the line-in audio jack. From here, the signals are amplified and sent to a total of ten band filter circuits which extract the target range of frequencies from the waveform and make them available to an analog multiplexer. This had to be done because the microcontroller, in this case an ESP32, has a limited number of analog-to-digital conversion pins, and thus needed several more to read the signals.
Users are able to control what the spectrum analyzer does via a control panel containing two buttons and three potentiometers, and power is delivered through another circuit which accepts 12V and regulates it down to 5V.
PCB assembly
Due to the large number of discrete components, it took Donners a while to place and solder each part. To prevent this issue, he recommended that fellow makers either use solder paste/hot air rework station or to simply get their boards from the fabricator pre-assembled. After the main board and auxiliary control board were finished, he wired them together via a set of twisted-pair wires.
Lights, adjustments, and more
The lighting system was added by first taking a string of individually addressable 5V LEDs and cutting them to the height of the grid. From here, Donners aligned it to the correct spacing and tacked each one into place before soldering wires between each strip in series, snaking fashion. Meanwhile, the control board was nested inside of the base compartment and connected to the adjustment panel in the front. With it, users can set the brightness, sensitivity, hold-time, and set the mode.
The Arduino sketch
Donners' use of an ESP32 not only meant that the system could quickly respond to changes in inputs, but that it also had Wi-Fi, Bluetooth, and plenty of RAM. The program starts by initializing the LED string and a web interface so that values can be seen in real-time by a web browser. After this, the loop continually cycle through the ten bands, reads them, and decides how the matrix should look when accounting for the current mode and settings.
Watch it go
As seen in the demonstration portion of the build log video, the spectrum analyzer has a clean, responsive look that can be easily modified through either software (for the LEDs) or by changing how the enclosure itself was constructed. To read more, you can find additional information here in Donners' blog post on the element14 Community.