Arduino syncs lights to music!

Reblogged from: http://paralluminati.blogspot.com/2013/04/arduino-syncs-lights-to-music.html

So I’ve been messing around with arduino for about a year and a half or so now and still don;t have much hardware to show for it but I have learned enough to last me.

Currently I’ve gotten the arduino working with stepper motors, simple ethernet web servers, bluetooth communications, and use with the labview drivers.  This post is for a project to entertain party guests with lights synced to music.

The Music

You can get the signal from the music being played by either splitting the signal going to the speakers by purchasing an audio splitter cable or you can use a microphone.  While the latter doesn’t offer as much in ease of employment it is readily available in breakout module form from various micro-electronics shops.

I decided to go with the microphone approach, above you see the analog mic (right) and the audio analyzer (left)both from DF Robot.  The mic sensor means I can utilize any audible source of sound for my lights or other uses.  The analyzer takes in the music signal and produces data regarding the intensities at different frequencies in the signal, thus allowing us to hone out things in the music to use to activate the relays for the lights like the bass, mid, and treble of a song or just make the most ridiculous sounds we can to see where our voices register in the frequencies.  The analyzer also comes with a arduino library to make things extra easy for us which can be found at DF Robot’s wiki site for the analyzer…you will need these libraries installed on your computer to be able to use my code example provided below.

The Arduino

The next step is reading the info from the analyzer and doing something with it.  This is where my code and their library come in.  I uploaded my code to media file HERE.  After uploading the code to the arduino we need a way for the pins to de/activate the lights so we use some relays.  Since mechanical relays have a finite life and create a bit of sound and typically require more than 5v to trigger, I went with a solid state relay.  To keep things compact I ordered a pre-made 4 channel 5v SSR board from SainSmart which is perfect for the arduino.  The arduino code defines which digital pins to hook the relay inputs to as well as which to hook the analyzer inputs to if you missed those in the analyzer wiki page.

At this point it is assumed you have the microphone hooked into the analyzer which is sending its data to the arduino which is telling the relay board which relays to activate.  Now all that is left is hooking up the lights to the relay board.  USA mains outlets have a Live and a Neutral and a Gnd, most light strands are only two wires though…dafuq??  No worries this is a common practice since when working with ac power we can use the N as a “ground” to complete the circuit thus eliminating the need for an individual ground wire, this is typically only used for low energy circuits such as led strips since they don’t require a heavy duty ground.  To hook the light strands up to the relays simply find the L in the power cable and cut it leaving the N intact. Then plug the ends of the L wire into the screw terminals on the relay board and tighten them down.  Plug the light cables into a wall outlet or power strip and you’re ready to jam.  Below is a video of a 3 light (Bass\Mid\Treble) set up I fashioned my apartment with before a party.  Definitely makes for an interesting beer pong game.

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: