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: http://stores.ebay.com/Sure-Electronics
The display I use: http://www.ebay.com/itm/P4-32X16-RG-Bicolor-LED-3mm-Dot-Matrix-Unit-Board-/350527814626?

Required Software:
  1) Arduino IDE (I am using version 1.0) found here: http://arduino.cc/en/Main/Software
  2) Processing IDE found here: http://processing.org/download/

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.


Processing:
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.

Arduino:
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: http://arduino.cc/en/
Processing homepage: http://processing.org/
Sure Electronics: http://stores.ebay.com/Sure-Electronics

More info on the libraries here
ledControl library homepage: http://arduino.cc/playground/Main/LedControl
ht1632c library homepage: http://arduino.cc/playground/Main/HT1632C

Great buyer's source for MAX7219:  Jameco.com
                                                           or  http://www.adafruit.com/products/453

Comments

author
nicholasjackson827 (author)2014-07-21

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: http://www.adafruit.com/product/420

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

author

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 https://learn.adafruit.com/32x16-32x32-rgb-led-mat...



EDIT:
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:
https://github.com/Aerospacesmith/RGB-matrix-Panel


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

Example:

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() {
matrix.begin();
matrix.drawLine(X1,Y1,X2,Y2,matrix.Color333(BLACK));
matrix.drawLine(X1,Y1,X2,Y2,matrix.Color333(ORANGE));
}
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.

author

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!

author

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
dotmatrix.fillScreen(BLACK);
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.

author
VinayC22 (author)2017-03-25

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?

author
Benb276 (author)2017-03-21

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

author
HydrogenCore (author)2016-07-18

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
Uno"

In file included from C:\Program Files
(x86)\Arduino\Audio_Spectrum_from_Processing_3216_double_bar_ino\Audio_Spectrum_from_Processing_3216_double_bar_ino.ino:1:0:

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!

author
KarolG9 (author)HydrogenCore2016-10-05

You need to use this library https://github.com/ACKspace/ht1632c
Connecting it directly like in tutorial will work. Connect +12V line 5V in arduino and GND to GND.

author
Carloo3 (author)2016-09-25

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?

Cheers

author
vaxus (author)2016-09-22

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

author
mwork5902 (author)2016-09-10

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

author
ponicki2 (author)2015-07-13

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!

author
LackingAce (author)ponicki22016-04-19

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!

author
jpmbtttt (author)2016-04-13

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

author
TordR1 made it! (author)2016-04-06

Thank you for the tutorial! Would it be possible to do this using addressable WS2811 LED strips that a are mounted in a row of 36 by 10 LEDs. I need them to be strips since I am placing the LEDs on fabric. Any recommendations would be greatly appreciated. Thank! The picture shows sort of what I am trying to achieve.

LED hammock scale .jpg
author
JosephKorso (author)2016-02-26

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

author
Joseph Korso (author)2016-02-26

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?

author
FrédérickC5 (author)2016-02-08

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.

author

2 -Processing code : I've combine Keanan code to code from the getline.in code in the minim example library. Now it proprely work, you also need to see you stereo mix in windows sound setting as recording device.


import ddf.minim.analysis.*;
import ddf.minim.*;
import processing.serial.*; //library for serial communication

Serial port; //creates object "port" of serial class

Minim minim;
AudioInput in;

FFT fft;
float[] peaks;
int peak_hold_time = 1; // how long before peak decays
int[] peak_age; // tracks how long peak has been stable, before decaying

// how wide each 'peak' band is, in fft bins
int binsperband = 5;
int peaksize; // how many individual peak bands we have (dep. binsperband)
float gain = 40; // in dB
float dB_scale = 2.0; // pixels per dB

int buffer_size = 1024; // also sets FFT size (frequency resolution)
float sample_rate = 44100;

int spectrum_height = 176; // determines range of dB shown

int[] freq_array = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int i,g;
float f;


float[] freq_height = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //avg amplitude of each freq band

void setup()
{
size(512, 200, P2D);

minim = new Minim(this);
//minim.debugOn();
// port = new Serial(this, Serial.list()[1],9600); //set baud rate
port = new Serial(this,"COM4",115200);

// get a line in from Minim, default bit depth is 16
//in = minim.getLineIn(Minim.mono, 512, sample_rate);
in = minim.getLineIn(Minim.MONO,buffer_size,48000);
// create an FFT object that has a time-domain buffer
// the same size as line-in's sample buffer
fft = new FFT(in.bufferSize(), in.sampleRate());
// Tapered window important for log-domain display
fft.window(FFT.HAMMING);

// initialize peak-hold structures
peaksize = 1+Math.round(fft.specSize()/binsperband);
peaks = new float[peaksize];
peak_age = new int[peaksize];
}

void draw()
{
for(int k=0; k<16; k++){
freq_array[k] = 0;
}

// perform a forward FFT on the samples in input buffer
fft.forward(in.mix);

// Frequency Band Ranges
freq_height[0] = fft.calcAvg((float) 0, (float) 50);
freq_height[1] = fft.calcAvg((float) 51, (float) 69);
freq_height[2] = fft.calcAvg((float) 70, (float) 94);
freq_height[3] = fft.calcAvg((float) 95, (float) 129);
freq_height[4] = fft.calcAvg((float) 130, (float) 176);
freq_height[5] = fft.calcAvg((float) 177, (float) 241);
freq_height[6] = fft.calcAvg((float) 242, (float) 331);
freq_height[7] = fft.calcAvg((float) 332, (float) 453);
freq_height[8] = fft.calcAvg((float) 454, (float) 620);
freq_height[9] = fft.calcAvg((float) 621, (float) 850);
freq_height[10] = fft.calcAvg((float) 851, (float) 1241);
freq_height[11] = fft.calcAvg((float) 1242, (float) 1600);
freq_height[12] = fft.calcAvg((float) 1601, (float) 2200);
freq_height[13] = fft.calcAvg((float) 2201, (float) 3000);
freq_height[14] = fft.calcAvg((float) 3001, (float) 4100);
freq_height[15] = fft.calcAvg((float) 4101, (float) 5600);


// Amplitude Ranges if else tree
for(int j=0; j<16; j++){
if (freq_height[j] < 200000 && freq_height[j] > 200){freq_array[j] = 16;}
else{ if (freq_height[j] <= 300 && freq_height[j] > 150){freq_array[j] = 15;}
else{ if (freq_height[j] <= 250 && freq_height[j] > 125){freq_array[j] = 14;}
else{ if (freq_height[j] <= 200 && freq_height[j] > 100){freq_array[j] = 13;}
else{ if (freq_height[j] <= 160 && freq_height[j] > 90){freq_array[j] = 12;}
else{ if (freq_height[j] <= 150 && freq_height[j] > 75){freq_array[j] = 11;}
else{ if (freq_height[j] <= 140 && freq_height[j] > 65){freq_array[j] = 10;}
else{ if (freq_height[j] <= 120 && freq_height[j] > 50){freq_array[j] = 9;}
else{ if (freq_height[j] <= 50 && freq_height[j] > 45){freq_array[j] = 8;}
else{ if (freq_height[j] <= 45 && freq_height[j] > 40){freq_array[j] = 7;}
else{ if (freq_height[j] <= 40 && freq_height[j] > 35){freq_array[j] = 6;}
else{ if (freq_height[j] <= 35 && freq_height[j] > 30){freq_array[j] = 5;}
else{ if (freq_height[j] <= 30 && freq_height[j] > 15){freq_array[j] = 4;}
else{ if (freq_height[j] <= 15 && freq_height[j] > 10){freq_array[j] = 3;}
else{ if (freq_height[j] <= 10 && freq_height[j] > 5){freq_array[j] = 2;}
else{ if (freq_height[j] <= 5 && freq_height[j] >= 1 ){freq_array[j] = 1;}
else{ if (freq_height[j] < 1 ){freq_array[j] = 0;}
}}}}}}}}}}}}}}}}}

/* background(0); // This code Draw the FFT on a black small windows, useful to //verify if it work, if you wan you want to test undo the // to make it active.
stroke(255);
// perform a forward FFT on the samples in jingle's left buffer
// note that if jingle were a MONO file, this would be the same as using jingle.right or jingle.left
// fft.forward(jingle.mix);
for(int i = 0; i < fft.specSize(); i++)
{
// draw the line for frequency band i, scaling it by 4 so we can see it a bit better
line(i, height, i, height - fft.getBand(i)*4);
}
fill(255); */
// End of windows drawing.

//send to serial
port.write(0xff); //write marker (0xff) for synchronization

for(i=0; i<16; i++){
port.write((byte)(freq_array[i]));
}
//delay(2); //delay for safety
}




void stop()
{
// always close Minim audio classes when you are done with them
in.close();
minim.stop();

super.stop();
}

author

I had lot of problem with processing not proprely reading audio input, also you arduino code miss something don't forget.
in void setup

dotmatrix.begin(); THIS one is VERY important, in all RGB example then have this matrix.begin(), you call yours dotmatrix, work fine.

Here my complete code for adafruit + arduino. it's not perfect yet, still no as smooth as I wish but it work
1 -Arduino code,

#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

RGBmatrixPanel dotmatrix(A, B, C, CLK, LAT, OE, false);
int array[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int arraytemp[16] ={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
int i,j,k,r;

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 ORANGE = dotmatrix.Color333(7,3,0);

void setup ()
{

dotmatrix.begin();
Serial.begin(115200);
dotmatrix.fillScreen(BLACK); // clear la matrix
}

void loop()
{
//protocol expects data in format of 17 bytes
//(xff) as a marker to ensure proper synchronization always
/*if (!Serial.available()>=17) {
for(r=0; r<17; r++)
array[r]=0;
}
*/

if(Serial.read() == 0xff){
for(i=0; i<16; i++){
array[i] = Serial.read();

}
//switch case statement
for(j=0; j<16; j++){
if(array[j]!= arraytemp[j]){

switch (array[j]) {
case 0:
dotmatrix.drawLine(2*j,0,2*j,15,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
break;
case 1:
dotmatrix.drawLine(2*j,0,2*j,15,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawPixel(2*j,15,GREEN);
dotmatrix.drawPixel(2*j+1,15,GREEN);
break;
case 2:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,14,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,14,GREEN);
break;
case 3:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,13,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,13,GREEN);
break;
case 4:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,12,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,12,GREEN);
break;
case 5:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,11,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,11,GREEN);
break;
case 6:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,10,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,10,GREEN);
break;
case 7:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,9,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,9,GREEN);
break;
case 8:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,8,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,8,GREEN);
break;
case 9:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,7,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,7,GREEN);
break;
case 10:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,6,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,6,GREEN);
break;
case 11:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,5,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,5,GREEN);
break;
case 12:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,4,ORANGE);
dotmatrix.drawLine(2*j,15,2*j,5,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,4,ORANGE);
dotmatrix.drawLine(2*j+1,15,2*j+1,5,GREEN);
break;
case 13:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,3,ORANGE);
dotmatrix.drawLine(2*j,15,2*j,5,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,3,ORANGE);
dotmatrix.drawLine(2*j+1,15,2*j+1,5,GREEN);
break;
case 14:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,2,ORANGE);
dotmatrix.drawLine(2*j,15,2*j,5,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,2,ORANGE);
dotmatrix.drawLine(2*j+1,15,2*j+1,5,GREEN);
break;
case 15:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,1,RED);
dotmatrix.drawLine(2*j,15,2*j,2,ORANGE);
dotmatrix.drawLine(2*j,15,2*j,5,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,1,RED);
dotmatrix.drawLine(2*j+1,15,2*j+1,2,ORANGE);
dotmatrix.drawLine(2*j+1,15,2*j+1,5,GREEN);
break;
case 16:
dotmatrix.drawLine(2*j,15,2*j,0,BLACK);
dotmatrix.drawLine(2*j+1,0,2*j+1,15,BLACK);
dotmatrix.drawLine(2*j,15,2*j,0,RED);
dotmatrix.drawLine(2*j,15,2*j,2,ORANGE);
dotmatrix.drawLine(2*j,15,2*j,5,GREEN);
dotmatrix.drawLine(2*j+1,15,2*j+1,0,RED);
dotmatrix.drawLine(2*j+1,15,2*j+1,2,ORANGE);
dotmatrix.drawLine(2*j+1,15,2*j+1,5,GREEN);
break;
}

arraytemp[j] = array[j];

}

}

}

delay(1);

}

author
mathew.adair.5 (author)2016-01-21

http://www.ebay.com/itm/Arduino-Uno-Compatible-Dual-Channel-MSGEQ7-Spectrum-Analyzer-Shield-Board-/321981951925?hash=item4af79eafb5:g:c2IAAOSwFqJWoHMZ

author
mfdupuis (author)2012-12-25

Hey! This is an awesome project, and I got it working. But now I'm trying to make a stand-alone system. Have you had any luck? What signal processing board do you use?

author
mathew.adair.5 (author)mfdupuis2016-01-21

http://www.ebay.com/itm/Arduino-Uno-Compatible-Dual-Channel-MSGEQ7-Spectrum-Analyzer-Shield-Board-/321981951925?hash=item4af79eafb5:g:c2IAAOSwFqJWoHMZ

author
pedroramalho (author)2012-06-28

HI,
This is very good. But I have only one question. Can I connect directly the sound to the arduino?

PedroRamalho

author

http://www.ebay.com/itm/Arduino-Uno-Compatible-Dual-Channel-MSGEQ7-Spectrum-Analyzer-Shield-Board-/321981951925?hash=item4af79eafb5:g:c2IAAOSwFqJWoHMZ

author
adam_kiroff (author)2015-12-15

im just wondering how the FFT program connects to the stereo mixer, the "java (tm) platform se binary pops up but is not reading any audio levels, iv tried playing stuff from youtube and plugin my iphone still not reading anything

author
heikichi.nguyen (author)2015-04-25

Thanks for the tutorial! but when i run the code on processing, there's and error: :(, help me pls !!

1.PNG
author

how did you fix this??? i am having the same problem

author
Keanan (author)heikichi.nguyen2015-04-26

Thanks for your inquiry,
This code was written in Processing 1.
It will have compiling errors in Processing 2.

Try running the code in Processing1

author
heikichi.nguyen (author)Keanan2015-04-27

I've tried on Processing 1 but the same error :(

Display 0 does not exist, using the default display instead.

WARNING: RXTX Version mismatch

Jar version = RXTX-2.2pre1

native lib Version = RXTX-2.2pre2

Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 1

at Audio_Spectrum_to_Arduino3216_doublebar.setup(Audio_Spectrum_to_Arduino3216_doublebar.java:68)

at processing.core.PApplet.handleDraw(Unknown Source)

at processing.core.PApplet.run(Unknown Source)

at java.lang.Thread.run(Thread.java:662)

123123.png
author
dathcha (author)2015-12-02

Awesome!!

author
JosiahS4 (author)2015-11-03

Is there a way that I can invert the output to the led's so they are inverted..like this

https://www.youtube.com/watch?v=OZyQ-g3klVU

author
galaxymaster1 (author)2015-10-21

I was wondering how you get the signal to the arduino? I want to be able to plug it into a audio desk. Is there anyway i can do this!???

author
dancopy (author)2015-08-26

Hi friend! First, thanks for the tutorial;
I have this module purchased on eBay - Then works with this ht1632c library?
Thank you

author
cheesemarathon (author)2015-04-15

So first of all when i run the processing script i get an error on line 45. Replacing the [1] with [0] allows it to run. However i have not got it to work yet as when i go into the arduino sketch to change the pins mine is wired up to i get an error as follows:

Audio_spectrum_from_Processing.ino: In function 'void _data_clr()':

Audio_spectrum_from_Processing:3: error: 'volatile struct bits' has no member named 'b10'

Audio_spectrum_from_Processing.ino: In function 'void _wr_clr()':

Audio_spectrum_from_Processing:3: error: 'volatile struct bits' has no member named 'b11'

Audio_spectrum_from_Processing.ino: In function 'void _data_set()':

Audio_spectrum_from_Processing:3: error: 'volatile struct bits' has no member named 'b10'

Audio_spectrum_from_Processing.ino: In function 'void _wr_set()':

Audio_spectrum_from_Processing:3: error: 'volatile struct bits' has no member named 'b11'

Audio_spectrum_from_Processing.ino: In function 'void _data_out()':

Audio_spectrum_from_Processing:3: error: 'volatile struct bits' has no member named 'b10'

Audio_spectrum_from_Processing.ino: In function 'void _wr_out()':

Audio_spectrum_from_Processing:3: error: 'volatile struct bits' has no member named 'b11'

Any help please Keanan?

author
harithal1 (author)2015-04-13

Errors:

Arduino: 1.6.3 (Windows 8.1), Board: "Arduino Uno"

Build options changed, rebuilding all

FY5KV8GGYZNVB9C.pde:8:1: error: 'import' does not name a type

FY5KV8GGYZNVB9C.pde:9:1: error: 'import' does not name a type

FY5KV8GGYZNVB9C.pde:10:1: error: 'import' does not name a type

FY5KV8GGYZNVB9C.pde:12:1: error: 'Serial' does not name a type

FY5KV8GGYZNVB9C.pde:14:1: error: 'Minim' does not name a type

FY5KV8GGYZNVB9C.pde:15:1: error: 'AudioInput' does not name a type

FY5KV8GGYZNVB9C.pde:16:1: error: 'FFT' does not name a type

FY5KV8GGYZNVB9C.pde:17:6: error: expected unqualified-id before '[' token

FY5KV8GGYZNVB9C.pde:20:4: error: expected unqualified-id before '[' token

FY5KV8GGYZNVB9C.pde:33:4: error: expected unqualified-id before '[' token

FY5KV8GGYZNVB9C.pde:38:6: error: expected unqualified-id before '[' token

FY5KV8GGYZNVB9C.pde: In function 'void setup()':

FY5KV8GGYZNVB9C.pde:42:16: error: 'size' was not declared in this scope

FY5KV8GGYZNVB9C.pde:44:3: error: 'minim' was not declared in this scope

FY5KV8GGYZNVB9C.pde:44:15: error: expected type-specifier before 'Minim'

FY5KV8GGYZNVB9C.pde:44:15: error: expected ';' before 'Minim'

FY5KV8GGYZNVB9C.pde:45:3: error: 'port' was not declared in this scope

FY5KV8GGYZNVB9C.pde:45:14: error: expected type-specifier before 'Serial'

FY5KV8GGYZNVB9C.pde:45:14: error: expected ';' before 'Serial'

FY5KV8GGYZNVB9C.pde:47:3: error: 'in' was not declared in this scope

FY5KV8GGYZNVB9C.pde:47:24: error: 'Minim' was not declared in this scope

FY5KV8GGYZNVB9C.pde:51:3: error: 'fft' was not declared in this scope

FY5KV8GGYZNVB9C.pde:51:13: error: expected type-specifier before 'FFT'

FY5KV8GGYZNVB9C.pde:51:13: error: expected ';' before 'FFT'

FY5KV8GGYZNVB9C.pde:53:14: error: 'FFT' was not declared in this scope

FY5KV8GGYZNVB9C.pde:56:16: error: 'Math' was not declared in this scope

In file included from FY5KV8GGYZNVB9C.pde:8:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:88:22: error: expected unqualified-id before '(' token

#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

^

FY5KV8GGYZNVB9C.pde:56:21: note: in expansion of macro 'round'

FY5KV8GGYZNVB9C.pde:57:3: error: 'peaks' was not declared in this scope

FY5KV8GGYZNVB9C.pde:58:3: error: 'peak_age' was not declared in this scope

FY5KV8GGYZNVB9C.pde: In function 'void draw()':

FY5KV8GGYZNVB9C.pde:65:1: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:69:3: error: 'fft' was not declared in this scope

FY5KV8GGYZNVB9C.pde:69:15: error: 'in' was not declared in this scope

FY5KV8GGYZNVB9C.pde:72:3: error: 'freq_height' was not declared in this scope

FY5KV8GGYZNVB9C.pde:92:58: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:93:62: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:94:62: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:95:62: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:96:61: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:97:61: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:98:61: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:99:61: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:100:60: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:101:60: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:102:60: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:103:60: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:104:60: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:105:60: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:106:59: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:107:60: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:108:36: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde:112:3: error: 'port' was not declared in this scope

FY5KV8GGYZNVB9C.pde:115:23: error: 'freq_array' was not declared in this scope

FY5KV8GGYZNVB9C.pde: In function 'void stop()':

FY5KV8GGYZNVB9C.pde:124:3: error: 'in' was not declared in this scope

FY5KV8GGYZNVB9C.pde:125:3: error: 'minim' was not declared in this scope

FY5KV8GGYZNVB9C.pde:127:3: error: 'super' was not declared in this scope

Error compiling.

This report would have more information with

"Show verbose output during compilation"

enabled in File > Preferences.

author
Keanan (author)harithal12015-04-14

The fft code doesn't go in Arduino, it goes in Processing.

author
harithal1 (author)Keanan2015-04-14

it didnt even compile to load.

the fft is not including in the program to compile

author
harithal1 (author)2015-04-13

sir i am unable to include fft library files pls help

author
Keanan (author)harithal12015-04-14

Your output shows that you tried to load the code in Arduino. The .PDE file goes in Processing. The .ino goes in Arduino.

author
projectabc (author)2015-01-27

First of all, thank you for the tutorial. If it wouldn't be much to ask, could you give a list of the materials and the quantity necessary?

Thank you

author
KylesER (author)2014-12-09

Hey, I was wondering if we could use this for the LED matix? https://www.sparkfun.com/products/12583

author
guven.hunerman (author)2014-10-28

Hi,I did all things about hardware but differently add microphone instead of jack input.

I have 16x64 rgb led panel and ard.uno.Before being crazy or broke everything please give me real working code or tell me something about hardware must change.

Thanks

author
achecopar (author)2014-09-25

I cannot find the code this article mentions, where is the link?

author
jmcclaire iii (author)2014-05-23

Nice job! I'm looking for some help with a project I'm working on. I'd like to display different animations on different LED matrix panels and control them all with one Arduino or BeagleBone Black. Any ideas? My failsafe is to combine several animations into one file and space them out so they look as if the different matrices are showing different animations.

Thanks for any advice or help anyone can offer!

- John

author
Romeo1981 (author)2014-04-17

how do I change the audio source? I want to use my music on my PC that is connected to my surround stereo system via Toslink and I would like to have the line in set to my speaker out (optical) so when I play music in media player or games or what not I want the sounds to display on the 32x16 bicolour matrix display. any help would be great, PS stereo system does not have preouts so I can't hook up a cable from my stereo, back to my computer line in.

author
Romeo1981 (author)Romeo19812014-04-17

also is there a way to change the speed it seems to have a delay from what comes out of the speakers to what is being displayed

author
mnedix (author)2014-01-06

It's a wonderful project, is it possible to make this without Arduino?

author
Keanan (author)mnedix2014-01-07

A microprocessor of some kind is required to drive the display.

author
mnedix (author)Keanan2014-01-07

Yes, an ATMega or a PIC will be required, I am really interested in a schematic + source code.

Anyone has such a thing?