Introduction: 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

Picture of 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

Picture of 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.


dcr0003 (author)2017-11-27

I tried this and this error message keeps coming up

exit status 1
'fft_lin_out' was not declared in this scope

TwWwIsT (author)2017-08-30

I have a problem with the Spectrum Analyzer ... so I made the spectrum analyzer the same way described in GreatScott!'s video and in this instructables. The problem is that when i upload the code to the Arduino, the spectrum analyzer doesn't light up any LED's in the matrix. The only thing that i changed is that i used two 1.6kOhm resistors instead of 1.8kOhm ones. In code, i changed ADMUX = 0b01000111; with ADMUX = 0x40; on line 54, so that i can use analog Inpit A0. When i open the serial monitor while playing music i can see changing values, and when i don't play music the values are not changing. Is the code processing the audio and the matrix not displaying it? Please help.

ljcorky (author)2017-03-08

i keep getting this error message. Arduino: 1.8.1 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

In file included from C:\Users\\Downloads\FRF9LJ5IVO3SD4B\FRF9LJ5IVO3SD4B.ino:16:0:

C:\Users\Documents\Arduino\libraries\FastLED-master/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.005

# pragma message "FastLED version 3.001.005"



\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.17\cores\arduino\main.cpp: In function 'main':


\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.17\cores\arduino\main.cpp:51:1: error: r28 cannot be used in asm here



C:\Users\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.17\cores\arduino\main.cpp:51:1: error: r29 cannot be used in asm here

C:\Users\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.17\cores\arduino\main.cpp:51:1: error: r28 cannot be used in asm here

C:\Users\\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.17\cores\arduino\main.cpp:51:1: error: r29 cannot be used in asm here

lto-wrapper: C:\Users\\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2/bin/avr-gcc returned 1 exit status

c:/users//appdata/local/arduino15/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.3-arduino2/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Arduino/Genuino Mega or Mega 2560.

This report would have more information with

"Show verbose output during compilation"

option enabled in File -> Preferences.

can you help?

HansbaldA (author)ljcorky2017-07-31

Install newest ArduinoFFT from here:
And it will work

FelixN18 (author)ljcorky2017-03-12

I met the same situation, but I solved the problem by replaceing the Arduino15 folder, which is in my C:\Users\\AppData\Local\Arduino15. It contains the core files for AVR programming. I replaced it with the original one(which is automatically built when you run Arduino IDE for the first time). Remember to backup! Hope this can help you.

FischiMc (author)ljcorky2017-03-10

I am really sorry but I can't really help you with the code because a friend of mine wrote it.
But it may be possible, that the problem occours because you use a arduino mega and not a nano. But I'm not sure.

IlyaR2 (author)2017-05-26

It's good result!

JanikH (author)IlyaR22017-07-18

What values for the frequencies and multipliers have you used for the two additional channels? I did the same thing but yours seems more reactive to the music.

AlexeyZ15 (author)2016-12-06

Good project you made here. Is using pin A7 necessary in this case, or I can use any other Analog input? I`m just using another diy arduino compatible board.

FischiMc (author)AlexeyZ152016-12-07

You can use any analog pin you like :) Just change it in the code

AlexeyZ15 (author)FischiMc2017-01-12

Thank you for the reply ^^ but...

I almost built my matrix and just realised how dumb I am... I made wrong led connection pattern like on the picture instead of your in the instruction. So every even column is reversed. I think it can be fixed with code. Colud you please help me with it, because its my first arduino project and I`m not familiar with coding yet. Thank you again.

FelixN18 (author)AlexeyZ152017-03-09

hello Alexey, I wonder how you changed A7 to another pin. You know, it's a

binary data. What if I want to use A0?

The original setting is :

ADMUX = 0b01000111; //use pin A7

(Line 54)

FischiMc (author)FelixN182017-03-10

I think pin A0 should be 0b01000000.

But I'm not 100% sure because a friend of mine actually wrote the code.

JanikH (author)FischiMc2017-07-18

It actually is 0x40.

DanB313 (author)AlexeyZ152017-01-29

Try this one

for(unsigned char y = 0; y < 10; y++){ //set colors of pixels according to column and hue

if(hs[column] > y){

if (y % 2) {

leds[(y*10)-column+9] = CHSV((hue*10)+(column*10), 255, 200);


else {leds[(y*10)+column] = CHSV((hue*10)+(column*10), 255, 200);


//leds[y+(column*10)] = CHSV((hue*10)+(column*10), 255, 200);

} else {

if (y % 2)

{leds[(y*10)-column+9] = CRGB::Black;

} else {

leds[(y*10)+column] = CRGB::Black;




FischiMc (author)AlexeyZ152017-01-14

I'm glad you're trying to follow my instructables. However I'm sorry that I can't really help you with the code because a friend of mine wrote it. Is there any chance to change your led connection to the one i showed in the instructables? (desolder the cables and solder them in the correct way)
Also check out my new video I made about the spectrum analyzer:

AlexeyZ15 (author)FischiMc2017-01-15

One more thing. I don't have 2x1.8k resistors at my hand so can I use 2x1.68k instead? I tried and it just doesn't work. No LEDs are lighting up. And serial monitor outputs some mes(if there is no music, its in one line and if there is an input then this mess is outputting in multiple lines).

FischiMc (author)AlexeyZ152017-01-16

1.68k resistors should work fine. I think the problem are not the resistors but the code. Are you able to send a screenshot of your serial monitor when you apply music to your arduino?

AlexeyZ15 (author)FischiMc2017-01-16


FischiMc (author)AlexeyZ152017-01-19

Sorry I forgot to mention that you have to open the Serial Plotter not the Serial Monitor. You can test your code with a video that plays a sine wave (such as this one) You then shoud see the sine wave on your serial plotter.

AlexeyZ15 (author)FischiMc2017-01-22

Seems like I used wrong Arduino IDE version, so by updating it to 1.6.7 problem was solved. Every second column is still reversed but that's still looks fine to me. Will post some photos later.

FischiMc (author)AlexeyZ152017-01-24

Nice :D Glad you got it to work :)

AlexeyZ15 (author)FischiMc2017-01-22

Also I can hear some pitch noise that the circuit outputs to 3.5 mm jack. Hope resistors with right value will fix this problem for me.

AlexeyZ15 (author)FischiMc2017-01-14

LEDs are already glued on its places so I can't change their pattern. Anyways, I found some code for zigzag matrix so will try to make a Frankenstein code for myself. Cool video :)

Patricio PedroB (author)2017-07-01

Would it be a problem if i use an arduino uno instead of the nano ?also im using regular led's is there a part of the code that i need to change because of that ?(sorry for grammar not my native language )

JanikH (author)Patricio PedroB2017-07-18

The arduino Uno and the Arduino Nano have the same chip, however the Nano uses the SMD version of it, so it has two analog pins more. That means that the Uno doesn't have the A7 pin used in the sketch. So you have to change this in the code to another analog pin, e.g. A0. I built the matrix with an Arduino Uno and it worked just fine. Just change 0b01000111 in line 54 to 0x40.

You can't however use this sketch with normal LEDs, you need the WS2812B LEDs with the built-in chip. You would have to program your own code and the wiring would be very messy, so I don't recommend that.

kolomir (author)2017-07-09

Really great work. I wanted to use your project but I have a problem with compilation. I have message "Low memory available, stability problems may occur." on my Arduino Nano. The program loads into Arduino but it does not work properly. Do you have any idea why I can not compile the program?

JanikH (author)kolomir2017-07-18

The "Low memory available" error shouldn't have an effect on the behavior of your sketch, at least it worked for me just fine with the error, so I ignored it. I rather think that a diffrent problem occurred, do you get another error? You can otherwise try to delete the lines for the serial monitor if you are not using it, because it is using quite a bit of system memory. Hope this helps you.

Killyax (author)2017-06-16

Can someone help me to adapt the code to an 70 led matrix? 7 large and 10 height

StevenR169 (author)2017-04-26

I have fixed the code issue I was having in uploading the sketch. I had
to delete the arduino15 folder and it seemed to do the trick. Now that
the code is on my Arduino Uno and I have changed the analog pin from a7
to a0 in the code, Im not too sure what digital pin the signal for the
LED matrix is supposed to come from? I found a signal on D3 and D1 but
they are only lighting up the first LED in my matrix chain. Am I even
using the right pins to connect to the LED matrix?

FischiMc (author)StevenR1692017-05-01

I'm sorry but I am not able to open the picture / video you added to your comment. Have you tried to upload an example sketch of the FastLed library to your arduino? It's always a good idea to test all parts of your project individually. I would suggest to upload a simple test program which you can find in the library to see if you have connected and configured the leds properly.

StevenR169 (author)2017-04-21

I have made my LED matrix and finally completed the circuit. So I turned my focus to the code thinking it will be a breeze after reading all of the comments and most people not reporting issues, but rather success stories. But of course I get an error upon compiling the code. I will say I am using Arduino IDE 1.6.9 and a Teensy 3.2 microcontroller which is compatible with Arduino.

The error read:

TIMSKO was not declared

Which came from the line:


I know you didnt write the code but do you know what is happening and why it wont compile for me but it will for most everyone else upon first try?

FischiMc (author)StevenR1692017-04-25

In case you didn't receive my private message:

please check your code again. I think you wrote TIMSKO istead of TIMSK0. The letter at the end must be a zero.

kind regards and good luck with your project!

FelixN18 (author)2017-03-10

I ran your code and a lot of "error: r29 cannot be used in asm here" came out, just the same as ljcorky 's comment. I tried to run fft_adc example code, but more errors occured. I even tried different IDE, including 1.8.1 and 1.6.7. TAT

Is that a common problem? Or just me? If the FFT library is not available, what can I do to replace it? Please help! THX

DanB313 (author)2017-01-29

Excellent code. Works only with 1.6.7

If you have a Matrix Horizontal Snake Bottom Left then the code can be hacked ->>>

for(unsigned char y = 0; y < 10; y++){ //set colors of pixels according to column and hue

if(hs[column] > y){

if (y % 2) {

leds[(y*10)-column+9] = CHSV((hue*10)+(column*10), 255, 200);


else {leds[(y*10)+column] = CHSV((hue*10)+(column*10), 255, 200);


//leds[y+(column*10)] = CHSV((hue*10)+(column*10), 255, 200);

} else {

if (y % 2)

{leds[(y*10)-column+9] = CRGB::Black;

} else {

leds[(y*10)+column] = CRGB::Black;




rafununu (author)2016-11-22

You only monitor one channel. Some stereo signals have huge differences between both channels so you could add left and right with resistors of high impedance. Your trick to shift up the signal is clever, I would have uses a reverse diode but this introduces distortion. Good job indeed.

FischiMc (author)rafununu2016-11-22

Thats true but ther are only few songs I now that habe such high differences. Furthermore I have already glued up my case and don't want to open it again.

DaBra (author)2016-11-22

Great Instructable, and really the first time I see a real spectrum analyzer without any additional analog or external graphic equalizing chip.

Any chance you can post a youtube video of the result?

FischiMc (author)DaBra2016-11-22

Thanks :) I already di upload a youtube video. The third picture is actually the video :) But due to a copyright claim it is without music. I am going to make a new video today.

Swansong (author)2016-11-21

Great instructable, this came out really well :)

FischiMc (author)Swansong2016-11-22

Thank you :)

mohammad_hasan (author)2016-11-21

nice work

FischiMc (author)mohammad_hasan2016-11-22

Thanks :)

About This Instructable




More by FischiMc:Arduino Spectrum Analyzer on a 10x10 RGB LED-Matrix
Add instructable to: