Raspberry Pi Audio Spectrum Display

by Arduino_having11_Guy in Circuits > Raspberry Pi

5665 Views, 14 Favorites, 0 Comments

Raspberry Pi Audio Spectrum Display

thumbnail.PNG
DSC_7719.JPG
DSC_7721.JPG

Use the DFRobot 64x64 RGB matrix panel with a Raspberry Pi 3 B+ to bring a dance party with you wherever you go!

DFRobot reached out to me to do a sponsored project for their 64x64 RGB
LED matrix. At first I had tried to use it with the ESP32 Firebeetle, but I couldn't get the library to work. So that meant using a Raspberry Pi 3 B+.

Link to products:

Raspberry Pi 3 B+:

https://www.dfrobot.com/product-1703.html

64x64 RGB Matrix:

https://www.dfrobot.com/product-1644.html

ESP32 FireBeetle

https://www.dfrobot.com/product-1590.html

Video

Raspberry Pi Audio Spectrum Visualizer

Here is a video demonstrating the matrix

Circuit

DSC_7728.JPG
DSC_7730.JPG
DSC_7726.JPG
DSC_7731.JPG
DSC_7732.JPG
DSC_7723.JPG
DSC_7718.JPG

Adafruit also has a guide that you can follow here: https://learn.adafruit.com/adafruit-rgb-matrix-pl...

Thankfully Adafruit has a matrix HAT for the Raspberry Pi that handles all of the 3.3v -> 5v logic level conversions.

Both the HAT and matrix have the same connector, but pin 8 (the white
wire) doesn't get plugged into the HAT. Because the HAT only supports up to 4 control wires, pin 8, which is the 5th control wire, gets connected to GPIO pin 24.

Make sure to use a 5V power supply that can supply up to 7A.

Library

For the attached code to work I used the rpi-rgb-led-matrix library to control the LEDs. It's pretty simple to install. Just run
curl https://raw.githubusercontent.com/adafruit/Raspbe... >rgb-matrix.sh

sudo bash rgb-matrix.sh

Then press y to continue and choose option 2 to select the Adafruit Matrix HAT.

Then choose number 2 to free up pin 18 so that sound can still be outputted over the audio jack.

To test it go into the examples-api-use directory and run
sudo ./demo -D0 --led-rows=64 --led-cols=64 --hardware-mapping=adafruit-hat

You should see the demo running. Just hit ctrl-c to exit it.

Running the Code

Before the code can run you must add the root user to the audio group with
sudo -su

then

modgroup audio

exit

Put the python file and test.wav file into /home/pi/rgb-led-matrix/bindings/python/samples/

If the demo ran fine then run the code with

sudo cd /home/pi/rgb-led-matrix/bindings/python/samples/

sudo python spectrum_matrix.py

You should hear the music playing from the audio jack and the lights lighting up.