Micro Disco!

May 3rd, 2014 3 min read

As some of you know, my dad is the one who thought me the basics of electronics. While I’m the computer guy, he’s the one building all the pretty stuff, and eventually became one of the best dutch model train builders.

Recently we were discussing the possibilities of incorporating an Arduino into his new layout. We both figured we should start with something simple, and came up with the idea of building a miniature disco.

This gave me a great opportunity to tryout the Adafruit Neopixel LED strips. But to make it even more fun, it gave me the opportunity to tryout a MSGEQ7 graphic equalizer display filter. This equalizer gives you the possibility to readout the amplitude of 7 separate frequency bands. These values, combined with the Neopixel Strips, is all you need to build your own disco show.

image

Athough the schematics for using the MSGEQ7 aren’t extremely difficult (4 capacitors, 1 resistor), I choose the easy route by ordering the Sparkfun Spectrum Shield, mainly because this shield includes a MSGEQ7 for both channels, and has an in- and output minijack connected to the board.

Before I could start the software part, I needed to wire everything up. The nice part about the Neopixels, is the fact that you can simply ‘daisy chain’ them, resulting in only one signal pin.

To do so, simply connect the DOUT of the first strip, to the DIN of the second strip:

image

After connecting the two LED strips, i connected them to +5v, GND and one of the digital outs. In this case I chose 7, simply because it’s my lucky number.

image

Time to connect the Spectrum Shield to the Arduino, and start the programming! After installing the Adafruit Neopixel Library I did some small tests to see if the LEDs worked. They did, so the next thing was figuring out how to use the Spectrum Shield.

First, I defined some PINS on the start of my program. I can use these defined macros later on, to refer to one of the pins. Adittionaly, I created two arrays that store the values for each band.

#define PIN\_NEOPIXELS 7
#define PIN\_STROBE 4
#define PIN\_RESET 5
#define PIN\_LEFT 0 //analog
#define PIN\_RIGHT 1 //analog

int left\[7\];
int right\[7\];

To readout the equalizer, I used one function, called a the start of every arduino loop:

void readMSGEQ7()
{
    //reset the data
    digitalWrite(PIN\_RESET, HIGH);
    digitalWrite(PIN\_RESET, LOW);

    //loop thru all 7 bands
    for(int band=0; band <7; band++) {
        digitalWrite(PIN\_STROBE,LOW); // go to the next band
        delayMicroseconds(50); //gather some data
        left\[band\] = analogRead(PIN\_LEFT); // store left band
        right\[band\] = analogRead(PIN\_RIGHT); // store right band
        digitalWrite(PIN\_STROBE,HIGH); // reset the strobe pin
    }
}

Every time this function is called, the arrays left & right are filled with data for each band. The amplitude is expressed as a value from 0 to 1023. The higher the amplitude, the higher the value. 

These value’s can be used the visualize the sound on the Neopixel LED strips. I’ve put an example on GitHub to demonstrate a VU meter.

After adding some extra visualization modes, I think I got my dad a pretty nice micro disco! Turn up the beat! :)

Questions? Or need some help in building your own Micro Disco? Drop them in the comments down below.

Loading comments …
©2021 - MichaelTeeuw.nl