Arduino / Processing Audio Spectrum Analyzer





Introduction: Arduino / Processing Audio Spectrum Analyzer

In this Instructable I am going to show how to make a program in Processing that analyzes sound on your computer and sends data to an Arduino that controls an LED matrix to show the spectrum analysis.

I will be explaining where to get materials, explaining the coding and wiring needed and providing example programs that can be adapted.

I will be using an Arduino Nano and and a 32x16 LED Matrix from Sure Electronics.

Step 1: Required Materials/Software and Where to Get Them

The required materials are:
  1) An Arduino(doesn't really matter which version/variant)
  2) LED Matrix (for this Instructable, I use a 32x16 bicolor matrix, but any matrix should work)
  3) A driver chip if your LED matrix doesn't have them integrated, I will be explaining this in more depth.

Inexpensive LED Matrices: Sure Electronics:
The display I use:

Required Software:
  1) Arduino IDE (I am using version 1.0) found here:
  2) Processing IDE found here:

Step 2: Wiring

The wiring for this matrix from Sure Electronics, wiring is really simple. The 32x16 bicolor(red, green) uses four HT1632C driver chips integrated into the back of the matrix. The driver chips are what are actually responsible for controlling all the LEDs in the matrix. This particular board is 32x16 'pixels' so to speak. But this is a bicolor matrix so there is actually 1024 LEDs on this board. Now that's a lot of LEDs, but because of the driver chips, we only use 4pins plus +5V and GND to connect the Arduino to the display. This display can also be daisy chained to 3 other displays and still only need 4 pins from the Arduino.

For other matrices, the wiring can range in difficulty. A standard 8x8 matrix needs 16 pins to control it without a driver chip. I will explain about driver chips in the next step.

The 4 pins needed are for the display's Data, CLK, CS, and WR. The connector on the driver chip should be labeled with these or be stated on the chip's datasheet. I have included the wiring for the 32x16 display as shown below. The pins used on the Arduino below can be changed, but the values in the coding must be changed to match.

Step 3: Driver Chips

For a 8x8 matrix, I would suggest getting a MAX7219. This driver chip can control a 8x8 matrix, or 8, 7-Segment displays and only use 4 pins plus a +5V and GND. The MAX7219 can also be daisy chained to another 9 drivers. There are other driver chips available, but the MAX7219 has an Arduino library in existence which makes coding easier for beginners.

Step 4: Coding

This spectrum analyzer is made of two parts: the Processing part that does a Fast Fourier Transformation (FFT) on the stereo mix of the computer and splits the audio into 16 frequency bands and finds their amplitudes and sends this data to the Arduino; then there is the Arduino part that takes the data from the Processing half and lights up the LEDs on the display according to the amplitude of each frequency band.

In the processing code, you can define your own frequency band ranges and amplitude ranges that correspond to the # LEDs on the display. The code I am including makes 16 bands that are 2 bars wide each to fill the display's range. This also quicker than sending 32 bands to the Arduino. The more data sent to the Arduino, the more lag the display has.

you need to extract the included libraries into you \Documents\Arduino\libraries    folder. If the libraries folder doesn't exist, make one labeled exactly "libraries". The first library ht1632c is for the display like mine. I have also included the ledControl library that is used with the MAX7219.

there are two important lines needed in this program:
#include <ht1632c.h>

ht1632c dotmatrix = ht1632c(PORTD, 7, 6, 4, 5, GEOM_32x16, 2);

the first line tells the compiler to include the ht1632c library. The second then makes a new structure called dotmatrix. anytime you want to call a function from the library, you need to call it with dotmatrix.'whatever'. The numbers and phrases in the parenthesis are: PORTD, DATA_pin, WR_pin, CS_pin, CLK_pin, GEOM_32x16, #ofdisplayschained. Here is where you can change which pins the display is connected to the Arduino. The #displayschained needs to be 2 unless you have more than two displays.

More info about the libraries can be found on the Sources page.
I am including the codes that are being used in my setup. If its not clear, the .pde is for Processing, the .ino is for Arduino. You can run both of the codes as is if you have the same display and setup as I have. You may need to make some changes to accommodate your setup.

Step 5: Sources

Arduino homepage:
Processing homepage:
Sure Electronics:

More info on the libraries here
ledControl library homepage:
ht1632c library homepage:

Great buyer's source for MAX7219:



  • Pocket-Sized Contest

    Pocket-Sized Contest
  • Pro Tips Challenge

    Pro Tips Challenge
  • Science of Cooking

    Science of Cooking

We have a be nice policy.
Please be positive and constructive.




Thanks for the tutorial! Unfortunately, I'm using a different LED matrix which includes different driver chips as well. Here is the matrix I'm using:

Is there an easy way to convert the code to work with the Adafruit_GFX or RGBmatrixPanel libraries? Thanks!

Well that display would be better driven by a more powerful microcontroller or FPGA, but it is possible. First wiring will require 12 pins on the Arduino. Using Adafruits GFX library will be a very smooth transition though. Mainly just replace and add the libraries, and change the line calls in the code to match the format of the GFX line methods: matrix.drawLine(X1,Y1,X2,Y2, matrix.Color333(r, g, b));

I'm not sure if the Color333(r,g,b) method understands a single uint32_t value instead of 3 r,g,b values, I'll look into it.

You don't need to call the dotmatrix.sendframe(); as the board automatically draws the lines when you call each drawLine method.

As I don't have this board, it will be difficult to help further, but if you have more questions, feel free to ask.

Also for more info, follow the tutorial at

Okay, I've been looking through the RGBmatrixPanel and the Color333 method does not recognize uint32_t variables, so my function above would not work, but I have submitted an issue request to Adafruit to add the feature, so maybe they'll add it, but I doubt it as they haven't changed it in 6 months.

But good news for now, I have forked the project and included the changes:

I also added the ability to call a Color(r,g,b) method.


RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
uint32_t BLACK = matrix.Color(0,0,0);
uint32_t ORANGE = matrix.Color(7,3,0); //Color333 uses values of 0-7.

void setup() {
void loop(){}

I have created test sketches and they compile so it should work, but again, I do not have this board so I cannot test if it actually works.

Please let me know if my altered library works.

Wow, I'm not sure what you did to the library, but it worked! I copied your example code directly, inserted some coordinates to draw an X on the matrix, and it worked! I also had to change the colors for BLACK real quick because the black didn't show up on the matrix (obviously).

What next steps do I need to take to get your rendition of the code to work? Thanks again for your time!

Sorry for not replying sooner. Life tends to get in the way very often.

Anyway, I'm not sure if you figured it out yet, but should be most/all the changes needed (hopefully):

#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library

#define CLK 8 // MUST be on PORTB! (Use pin 11 on Mega)
#define LAT A3
#define OE 9
#define A A0
#define B A1
#define C A2

Make your new matrix library call:
RGBmatrixPanel dotmatrix(A, B, C, CLK, LAT, OE, false);

Then before setup() add the various colors, example Orange is 7,3,0; Red 7,0,0; Green 0,7,0 or ANY color you want since you have that board.
Just make sure to declare them as uint32_t types like

uint32_t BLACK = dotmatrix.Color333(0,0,0);
uint32_t GREEN = dotmatrix.Color333(0,7,0);
uint32_t RED = dotmatrix.Color333(7,0,0);
uint32_t YELLOW = dotmatrix.Color333(7,3,0);

Remove the dotmatrix.clear(); and replace it with
this essentially fills the screen with black and clears it.

Then in each line call: dotmatrix.line(x1,y1,x2,y2,color); change the method from line to match the new libraries drawLine.
ex: dotmatrix.drawLine(x1,y1,x2,y2,GREEN);

Change the pixel calls from dotmatrix.plot(x,y,color); to dotmatrix.drawPixel(x,y,color).

And finally remove the dotmatrix.sendframe(); as this library/matrix driver pushes and draws the screen on every draw command and doesn't need a draw screen command. However this is also a caveat as drawing the screen on each command will slow down the display.

How do you sample sound on it? Through an audio file? Can I create a microphone as an input? What I am asking is what is the input?

any way of doing this without using a LED matrix as I'm wanting to use a different layout for the LED's

Great job Keanan. I got DE-DP14116 the re-designed 3216 3mm from Sure Electronics. The connector is different and it requires a 12V power supply.

Whats the wire diagram from the 10pin connector to Arduino for DE-DP14116?

Secondly I got Arduino compile errors. Suggestions?

Arduino: 1.6.9 (Windows 10), Board: "Arduino/Genuino

In file included from C:\Program Files

C:\Program Files
(x86)\Arduino\libraries\ht1632c/ht1632c.h:168:34: error: 'prog_uint16_t' has
not been declared

void putbitmap(int x, int y,
prog_uint16_t *bitmap, byte w, byte h, byte color);


C:\Program Files
(x86)\Arduino\libraries\ht1632c/ht1632c.h:192:5: error: 'prog_uint8_t' does not
name a type

prog_uint8_t *font;


C:\Program Files
(x86)\Arduino\libraries\ht1632c/ht1632c.h:193:5: error: 'prog_uint16_t' does
not name a type

prog_uint16_t *wfont;


exit status 1

Error compiling for board Arduino/Genuino Uno.

Thanks in advance!

Everything works ok for me, but i having a lot problems with sending the audio source from my computer to processing, how can i solve it?


I was excited to read the article, wow arduino and analyzes the audio.... but unfortunatelly it is not - the name is misleading. Arduino is used just to show LED matrix. What a pity...

p.s. I am considering to make a project "Arduino + audio analyzer chip". But is becomes very expensive..... I should go back to old fashion several "resistors+inductions" audio solution :-)