Backend / DevOps / Architect
Brit by birth,
located worldwide

All content © Alex Shepherd 2008-2024
unless otherwise noted

Arduino/MSGEQ7 Audio Spectrum LED Display

Published
2 min read
image
Image Credit: Unknown (if this is your work, reach out to me and I'll credit you!)

Hi guys!

Another Arduino-related post today. I've created a basic audio spectrum analysis circuit based around the MSI MSGEQ7, which is a 7-band Graphic Equaliser Display Filter. It basically takes an audio input, and spits out 7 logarithmic scale frequency amplitude values between 63Hz and 16KHz. While this can be done to a far more accurate scale by running a Fast Fourier Transform on an audio signal, the Arduino isn't greatly suited to this task. It's possible to do this on a computer, and transmit the constrained values to the Arduino, but why use all those processor cycles, when there's such a useful little IC which does it for you for only a few quid?

Connecting the MSGEQ7 to the Arduino is a fairly simple task, even for an electronics newbie like myself. I followed J. Skoba's guide for the most part, but substituted some of the parts for components I had lying around, and it worked just fine. The project requires:

  • 4 x 0.1uF ceramic capacitors
  • 1 x 220K Ohm resistor
  • 6 x 250 Ohm resistor (current limiters for RGB LEDs)
  • 3 x TRS audio jacks
  • 1 x TRS audio plug
  • 1 x 3.5mm TRS to 3.5mm TRS audio cable
  • A connector to attach a 3.5mm jack to an audio amplifier or powered speakers (I used a 3.5mm TRS to 2 x RCA lead)
  • 2 x common cathode RGB LEDs
  • A whole mess of jumper wires

Here's the schematic to see how to hook everything up. Sorry about the crappy resolution. If anybody wants a higher res version, just let me know, and I'll see what I can do. Here's a breadboard diagram made in Fritzing. Way better quality that the other pic I had, and the pins are right too, which helps :-P. If you want an SVG version, I've saved one in the same folder. Just change the filename in your address bar. I didn't include it in the article as it appears to have missed R1 for some reason.

Here's a couple of pictures of my breadboard to help you out if you're still having problems.

The code I used is a mixture of my own, and that of a few sources on the Internet; the most notable of these is J. Skoba's Arduino/MSGEQ7 tutorial. Here's the code for your perusal and use:

/**
 * Author: n00bsys0p (n00bATNOSPAMn00bsys0p.co.uk)
 * Date: 13/01/12
 * Arduino: Uno v3
 *
 * Arduino code for use with my MSGEQ7 schematics.
 * Find the schematics to go with this on my blog at:
 * http://n00bsys0p.co.uk
 *
 * Most of this is sourced from J. Skoba's guide at:
 * http://nuewire.com/info-archive/msgeq7-by-j-skoba/
 *
 * Other parts sourced from various other places
 * online. If you recognise your code, THANK YOU!
 *
 * Massive thanks to the Arduino community for being
 * so open and so giving!
 *
 * I found his personal site at no-ip.org to be offline
 * a lot, so use this link if you have trouble.
 */

int analogPin = 0; // MSGEQ7 OUT
int strobePin = 2; // MSGEQ7 STROBE
int resetPin = 4; // MSGEQ7 RESET
int spectrumValue[7];

// MSGEQ7 OUT pin produces values around 50-80
// when there is no input, so use this value to
// filter out a lot of the chaff.
int filterValue = 80;

// LED pins. I used 2 common cathode RGB LEDs.
// They're connected to the PWM pins on the Arduino
int ledPinR1 = 3;
int ledPinG1 = 5;
int ledPinB1 = 6;

int ledPinR2 = 9;
int ledPinG2 = 10;
int ledPinB2 = 11;

void setup()
{
  Serial.begin(9600);
  // Read from MSGEQ7 OUT
  pinMode(analogPin, INPUT);
  // Write to MSGEQ7 STROBE and RESET
  pinMode(strobePin, OUTPUT);
  pinMode(resetPin, OUTPUT);

  // Set analogPin's reference voltage
  analogReference(DEFAULT); // 5V

  // Set startup values for pins
  digitalWrite(resetPin, LOW);
  digitalWrite(strobePin, HIGH);
}

void loop()
{
  // Set reset pin low to enable strobe
  digitalWrite(resetPin, HIGH);
  digitalWrite(resetPin, LOW);

  // Get all 7 spectrum values from the MSGEQ7
  for (int i = 0; i

I split the audio from my laptop to an amplifier and the circuit by making a simple splitter with 3 TRS audio jacks, connecting the single end to my laptop, one of the double end to the circuit, and the other to my amplifier. I also used a TRS plug instead of a TRS socket on the circuit, as the schematic shows. I'll add some pictures shortly to show you how my breadboard is set up.

I don't think that there's much else to do, than include a video of the final build. Sorry about the terrible editing in the video, and the hurried nature of this post. I'll do my best to improve it at a later date.

As always, direct any questions to the contact form or comments!

n00b