Introduction: LoL Shield Audio Spectrum VU Meter

About: This space intentionally left blank.
This is an audio spectrum VU meter using the LoL Shield for Arduino .

The LoL Shield is a 14 x 9 LED matrix which fits onto the Arduino as a shield and is controlled through an efficient method known as Charlieplexing . It was designed by Jimmie P. Rodgers .

This project uses a Fast Fourier Transform library for Arduino to analyze an audio signal, break it up into frequency bands, and display that information on the LoL Shield.

The Arduino microcontroller is fast enough to calculate a fast Fourier transformation. It lives up to its name and is surprisingly fast and accurate.

Since all the work is done by the microcontroller, this project is completely portable if you use batteries.

The webpage for this project is located at http://andydoro.com/vulol/



Parts required:
  • LoL Shield
  • Arduino (Diavolino recommended)
  • audio jack (I used a male mono 1/8" phone plug)
  • Arduino code
  • power supply (DC power supply, USB cable, 9V battery, etc.)

Step 1: Assemble LoL Shield


Follow the instructions to assemble the LoL Shield here .

See, that didn't take long at all!

Step 2: Solder Wires to the Audio Jack


I am using a male mono 1/8" phone plug, as it's called at Radioshack, but you can use whatever audio cable is appropriate for your audio system setup. You could use a microphone if you wanted to.

For this type of plug, I soldered two wires. I used red and black.

The LoL Shield leaves analog pins 4 and 5 free for inputs. My code uses pin 5.

You can attach the red wire to analog pin 5 of the LoL Shield and the black wire to GND. You don't need to solder it in, I just put the wire through and bent it.

Step 3: Program Arduino

Now we need to program the Arduino to control the LoL Shield.

It is recommended to use the Diavolino to control the LoL Shield in order to prevent "ghosting" effects on the LEDs due to the green surface mount LED connected to pin 13 on the standard Arduino, but a standard Arduino will work fine.

This requires two Arduino libraries:
- the FFT library found on the Arduino forum
- the Charlieplexing library for the LoL Shield

Installing libraries for Arduino can be slightly daunting if you haven't done it before, but you'll do fine!

Follow the instructions on installing Arduino libraries here:

http://www.arduino.cc/en/guide/libraries

The FFT library breaks the audio signal in 64 frequency bands.
The LoL Shield is 14 x 9 LEDs. We average the 64 frequency bands together into 14 frequency bands. We're throwing away some data because 14 doesn't divide into 64 evenly, but whatevs.
The value of each frequency range is remapped from 0 to 9.

You can copy the Arduino code below, get the code from GitHub (recommended), or download the .ZIP file, which includes the libraries and Arduino code.

Here is the GitHub link:

https://github.com/andydoro/LoLShield-FFT

Below is the Arduino code:

/*
FFT for LoL Shield v0.9
by Andy Doro
http://andydoro.com/
based on FFT library and code from the Arduino forums and
the Charlieplexing library for the LoL Shield.
*/

#include "Charliplexing.h"

#include "fix_fft.h"

#define AUDIOPIN 5
char im[128], data[128];
char data_avgs[14];

int i=0,val;

void setup() {
LedSign::Init(); //Initilizes the LoL Shield
}

void loop() {

for (i=0; i < 128; i++){
val = analogRead(AUDIOPIN);
data[i] = val;
im[i] = 0;
};

fix_fft(data,im,7,0);

for (i=0; i< 64;i++){
data[i] = sqrt(data[i] * data[i] + im[i] * im[i]); // this gets the absolute value of the values in the array, so we're only dealing with positive numbers
};

// average bars together
for (i=0; i<14; i++) {
data_avgs[i] = data[i*4] + data[i*4 + 1] + data[i*4 + 2] + data[i*4 + 3]; // average together
data_avgs[i] = map(data_avgs[i], 0, 30, 0, 9); // remap values for LoL
}

// set LoLShield

for (int x=0; x < 14; x++) {
for (int y=0; y < 9; y++) {
if (y < data_avgs[13-x]) { // 13-x reverses the bars so low to high frequences are represented from left to right.
LedSign::Set(x,y,1); // set the LED on
} else {
LedSign::Set(x,y,0); // set the LED off
}
}
}

}

Step 4: Enjoy!!

Plug the audio jack to your stereo, iPod, computer, etc.

Power the Arduino with a DC power supply, USB from your computer or batteries- this is completely portable. You could put it into a hat or belt buckle.

The white LEDs are so bright it's difficult to capture on video. It looks like there is purple flame coming off of them!

Sit back and enjoy!