Arduino Spectrum Analyzer on a 10x10 RGB LED-Matrix

54K276124

Intro: Arduino Spectrum Analyzer on a 10x10 RGB LED-Matrix

In this Instructables I am going to show you how to create a spectrum analyzer powered by an Arduino nano. Please watch my video first to get a rough explaination on how to build it.

A spectrum analyzer basically analyzes the intensity of different frequencies in a song. To display those values we are going to use a 10x10 RGB LED-Matrix. Every time one of the columns reaches the top of the matrix the hue value of the colors increases and the matrix looks different.

STEP 1: Building the Matrix


To make this awesome spectrum analyzer I first had to build the RGB LED-Matrix. To accomplish this task I have followed the Tutorial of GreatScott on YouTube. He did an awesome job in explaining how to build such a matrix. Just follow the video step by step or use his Instructables as an instruction and then come back and follow the next steps.

Important note: make sure your LEDs are connected as shown in the diagram above. Otherwise my sketch won't work flawless with your matrix.

STEP 2: Additional Parts

To convert your Matrix into a spectrum analyzer you need the following additional components:

  • 2x 3.5mm headphone sockets
  • 2x 1.8kOhm resistors
  • 1x 4.7kOhm resistor
  • some flexible wire

First of all I had to include the two headphone sockets to the matrix. We use them to loop the audio signal through the matrix to analyze it. We basically connect our audio source (e.g. a smartphone) to one of them and a speaker to the other one. I just drilled two holes according to the diameter of my sockets and glued them in place with two component adhesive.

In the next step you will see why we need those resistors.

STEP 3: Connecting the Components

First of all, I have connected 3.3V to the AREF pin of the Arduino through a 4.7kOhm resistor. This is to get a better resolution of the sampled values of the audio signal since they normally reach a maximum of only 1V Peak-to-peak. The reason why we get a better resolution is that the 1024 values of the ADC are now not longer mapped to 0-5V but to 0-2.88V (2.88V because of the 4.7kOhm resistor). To understand why we used a 4.7kOhm resistor and how I have calculated those 2.88V have a look at the analog reference article on the Arduino website.

But there is one problem if you want to analyze an audio signal with an Arduino. The signal is mirrored around 0V. Therefore we get both positive and negative voltage peeks. And because Arduinos can't handle negative voltages we have to get rid of them and create an offset.

As you can see in the schematic above I used a voltage divider with two 1.8kOhm resistors to solve this problem. Since they have both the same resistance the signal now alters around 1.44V (2.88V/2) and we got rid of those negative voltages. To make life easier you can solder the resistors directly to the pins of your Arduino nano.

Lastly I connected the two audio jacks. I simply connected both right and both left channels to each other. I then soldered both GND pins together and connected them to the GND wire of the matrix. Which of the two channels you then connect to the Arduinos A7 Pin / voltage divider doesn't really matter.

STEP 4: Programming

To program the built in Arduino nano you first of all have to download both the FastLED and the FFT library. Make sure you have exactly these versions of the libraries listed below otherwise the sketch may not work. Also check if you use at least Arduino IDE 1.6.8 or higher. After you have included both libraries into your Arduino IDE you have to open the "SpectrumAnalyzer" sketch.

Now change the data pin of your LEDs, upload it to your Arduino, connect an audio source and speakers and it is done!

Hope I could help you with this Instructables. If you have any questions feel free to ask them in the comments section below.

98 Comments

That input circuit is a mess and risks damaging your audio device and your Arduino. You have not understood what you have read on the Arduino page.
R2 should be connected to ground not your audio input. Your audio input should be connected to A7 through a series capacitor. You should not connect anything to the Aref input and R3 should go straight to the 5V connector.
Hey Grumpy Mike, could I hook up a speaker directy to the schematic instead of using audio inputs. If so how can i hook it up to the rest of the system.
No, a connection from a speaker is not suitable as an input. This is because it is a differential signal, that is one lead goes positive while the other goes negative. Then they swap over with the positive going negative. It is these negative signals that will destroy your Nano input pins. To use a speaker you would need an audio transformer with a center tapped secondary biased at half rail, followed by a differential input operational amplifier.
Thanks for the reply Mike.
R2 and R3 are not pins in the Nano. They are resistors that are connected to pins. As it stands on the original diagram R3 is connected between the Aref and the A7 pin on the Nano, and R2 is connected between A7 and the audio input.
Hi, I tried to compile the ino file before to load it in a nano and I've got error - r28 cannot be used in asm here, same with r29.... Can you help me to solve it? I use Arduino 1.8.13 and libraries indicated above.
Use arduino version 1.6.7 or use the updated code
Hello,

I have a Arduino Mega that came with a kit and I am having trouble getting the code to load. Do you have any suggestions?
I built this and it seems to work great for regular music - but I'm using it with a guitar amplifier and noticing that even with there being no sound (including hum or anything, just complete silence) I still get almost full peaks showing.

Is there a way to adjust the sensitivity through code, instead of having to solder in new resistor values (and guess around with that until I get the right ones)?

Thanks for the code, though - works great!
Great project FischiMc. Thank you for posting.
As I am new to
Arduino and am looking to build this so I might be asking a silly
question here. Can someone post a diagram as to how the LED strip
connects to the Arduino board?
Does the power supply still connect
directly the LED strip also go to Arduino 5V pin and ground as well as
data from LED strip to D3? Then we simply add the components listed in
your schematic? Also which lines need to be modified to in number of
rows or columns? EG 15 rows x 20
Ive already soldered the LED's as described in the video just wanting to clarify.

Thank you
Would it be possbile to use the esp8266 for this
I honestly have no clue since I have never played with one. I may think about getting one though since it has WiFi built in. For now, I only got the Arduino working and you can use a Bluetooth module to change colors.
i have just got myself a esp8266 and am currently working on a code for it that will have a web based gui. I am going off of someone else's code but tying to adapt it to work for this guide. if you are still interested, let me know and ill try and help you with setup.
Do you know if it's possible to run this on a Photon Particle? Or is it even worth having..
Hi! Can I ask what parameters I should change in your code in order to implement this on a 3x10 Matrix? I want to use this for 3 frequencies only. Thanks a lot!!
More Comments