Hand tools and fabrication machines
I've always been fascinated with the mysterious, sometimes beautiful patterns that can arise from mathematics. In freshman year of college, I was exposed to Conway's Game of Life, and was fascinated with the complicated dynamics that could arise from such a simple set of rules. Combine this with my newfound passion for EDM, and a compelling project basically made itself.
The sound sensitive display updates its display according to Conway's Game of Life. The basic principles of operation are as follows:
- The PocketBeagle initializes a random seed of The Game of Life
- A sound detector reads and processes sound data from the environment and determines the timing of "beats" in the music playing in the environment.
- At each beat, the microprocessor computes the next iteration of the game of life, and sends this data to the makeshift LED matrix
- The LED matrix lights up accordingly
- This continues until the entire game board is dead, in which case a new seed of The Game of Life is generated
The hardware elements of this project are relatively simple and easy to work with. The main hardware elements are as follows:
- NeoPixel LED strip (in the form of an LED Matrix)
- Sparkfun Sound Detector
First, one should deal with the LED Matrix, as that proves to be the most challenging aspect of this project. The choice of LED matrix is a critical one that will influence many aspects of the project.
Initially, I attempted to use the more conventional 32x32 LED matrix sold by Adafruit (https://www.adafruit.com/product/1484). However, the lack of a dedicated Linux library for this project and poor documentation in general made working with the matrix prohibitively difficult. Instead, Adafruit NeoPixel LED strips are easy to work with and provide the same functionality, albeit in a less convenient form. (Read the following link to get detailed information on NeoPixel wiring, sample code, and tips and tricks: https://learn.adafruit.com/adafruit-neopixel-uberguide)
Some physical work needs to be done to convert the strip of LEDs into a "matrix" of LEDs. First, divide the NeoPixel string into strips of your desired matrix size, making sure to use sharp scissors and cut along the bronze or silver solder pads (cut as many strips as there are LEDs in each strip if a square matrix is desired)
Next, cut an appropriately sized piece of wood (10" by 10" for a 15x15 matrix) and glue your strips onto the wood in matrix form as seen below. Note that in order to obtain an even aspect ratio on your matrix, you must leave space between each LED strip that you place on your board. Also, the arrow referring to data flow must point in opposite direction on consecutive strips so that data flows in a correct manner when the board is soldered.
By cutting the NeoPixel into strips, the connection between strips was severed. A careful soldering job is required to maintain continuity of the matrix. Starting at the bottom left corner at the connection to the rest of the circuit, solder jumper wires between 5V-5V, GND-GND, D0-DIN so that the connection "snakes" up the matrix all the way to the top strip. Soldering these delicate and close connections is somewhat of an art, but it may be helpful to pre-apply a dot of solder to the solder pads, then press your wire onto the solder pad and remelt the solder. Below is a more detailed image of soldered connections between LED strips.
The sound detector and the PocketBeagle are good to use as is. However, you may find it necessary to adjust the sensitivity of the sound sensor by populating R17 on the board in accordance with the following documentation: (https://learn.sparkfun.com/tutorials/sound-detector-hookup-guide?_ga=2.135478513.1535210145.1574136336-1929768982.1567124256)
Additionally, it may be helpful to install female headers onto your PocketBeagle for prototyping purposes.
Below is the Fritzing diagram for the system:
The PocketBeagle is connected directly to the sound detector via P1_19, and to the NeoPixel via P1_8.
It will be helpful to break down the fritzing diagram into parts, and explain each one in more detail.
As is recommended in the NeoPixel guide, a 100 microFarad capacitor was added to the system to prevent surges in voltage from negatively affecting the LED strip. Additionally, we add a 47 Ohm resistor between the power supply ground and the PocketBeagle ground to reduce noise for the Sound Detector.
LED Data Signal Processing:
Again, the recommendation provided by the NeoPixel guide was followed: a 470 Ohm resistor was added between to the data input so as to protect the LEDs from voltage spikes. The CJMCU unit is required to shift the GPIO output from the PocketBeagle from 3.3V to the required 5V of the NeoPixel strip.
Sound Detector Analog Output Processing:
The Sound Detector outputs data at 5V, while the PocketBeagle AIN port can only handle 1.8V. Therefore, we must construct a voltage divider to reduce the Sound Detector output voltage to the necessary level.
After downloading the github repository and following the instructions found in the readme, the project should run effectively. This assumes you have python, pip, and the Adafruit BBIO libraries installed on your PocketBeagle already.
Before running the project, you must type the following:
config-pin P1_8 out
Individual components of the project saw success. The code was successfully able to display and update the Game of Life on the makeshift LED matrix, as seen in the video below.
Unfortunately, due to an unfortunate accident with the LED strip, all LEDs were burnt out before the project was able to be fully integrated. However, the audio processing algorithm that I developed was demonstrated to work very effectively. With a functional LED strip, the project should (in theory) be able to function with no modification whatsoever.
In the video below, the visual output of a functioning LED matrix is simulated via print statements which encode the state of the game board. It can clearly be seen that in the absence of sound input, the board state changes at a consistent rate, and when music is added into the environment, the board begins to update along with the music. The first video shows a proof of concept with an ideal music file, and the second video depicts a more realistic use case.
This project was reasonably successful, but there are a few steps that could be implemented in the future to improve it further:
- Implement a more advanced beat sensing algorithm using FFT algorithms to detect beats more effectively in songs in which they are less obvious
- Use a functioning LED strip to ensure that the code is properly integrated
- Add a button that changes the color of the LED matrix
- Use a more official LED matrix to improve the aesthetics of the project