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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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:

Arduino Challenge

Participated in the
Arduino Challenge

1 Person Made This Project!


  • Instrument Contest

    Instrument Contest
  • Make it Glow Contest

    Make it Glow Contest
  • STEM Contest

    STEM Contest

71 Discussions

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.


Question 6 weeks ago on Step 5

Hi. Do u think it is possible to input the audio from a cinch?


Question 5 months ago

can you use the audio spectrum on a 32X32 led matrix?


Question 6 months ago

Hey I've been having this error for a while now and my partner and I are totally stuck.

In file included from C:\Users\JoseJ19\Downloads\FSHKZKAGZ0BVJOC\FSHKZKAGZ0BVJOC.ino:1:0:
C:\Users\JoseJ19\Documents\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:\Users\JoseJ19\Documents\Arduino\libraries\ht1632c/ht1632c.h:192:5: error: 'prog_uint8_t' does not name a type
prog_uint8_t *font;
C:\Users\JoseJ19\Documents\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.

Any ideas? Also, we did try using a Nano before but we had the same issue. I can send pictures of our wiring too if that helps.


2 years ago

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?


2 years ago

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


3 years ago

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!

1 reply

3 years ago

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?



3 years ago

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


3 years ago

Is there any chance you would know of pin out for the DE-DP14116 12volt version of your board. They redesigned it but cant supply any documentation so cant connect to it, yet


4 years ago on Introduction

Hi guys! I'm working on a project for class and I was wondering if anyone could help me figure out how to pick up a note through waveform when played on a guitar so it is read through the computer microphone and transferred to spectrum analysis? Thanks!

1 reply

Reply 3 years ago

best way i can think of is to use virtual audio cable. It creates and combines a output source and input source. so then you use the included software to send your input (your Guitar) into the virtual audio cable output. if you are having troubles, pm (Private message) my Instructables account. :D Good Luck!


3 years ago

You don't use any audio chips ? Because i'm seeing in other projects people using.


3 years ago

Do you have a video showing the visual effect acquired with this project?

Joseph Korso

3 years ago

LED Matrices even these ones with drivers included are based on anode common/catode common. Do you think I can use a different arrangement of this matrix if I use a bigger one, but with same number of rows and LEDs? I mean, the display itself it's too small for the purpose I'm using them for, so in theory, I could another matrix with a bigger set position but same config and plugges in the same fashion in the driver and all, couldn't I?
This is meant for stereo sound and shows both channels or I would have to build a second one if I needed a separated channel spectrum analyser?


3 years ago

HI, I made processing ( using 1.51 instead of the new 3.0, because it doesn't seem to work with 3.0) and arduino work. Your new code for Adafruit Matrix compiled perfectly ( even better than the first one in my case). So, the source of sound is the computer or the line in? If I play music from my PC ( With foorbar or WMP for example) will it work? or this have to come from the line in? And can we switch source? I don,t have the Led matrix yet to fully test it. Also you arduino code for led control could potentially by modified to display anything? like text I supposed.

Thank and great project.