Arduino / Processing Audio Spectrum Analyzer

262,602

267

68

Published

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

Share

Recommendations

  • Casting Contest

    Casting Contest
  • Woodworking Contest

    Woodworking Contest
  • Clocks Contest

    Clocks Contest
user

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

Tips

Questions

68 Comments

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!

3 replies

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.

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

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
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!

1 reply

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

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

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

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

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!

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

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

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?

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.

2 replies

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();
}

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

}

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