Monthly Archives: August, 2013

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

‘Knock Back’ – A Knock Echoing Arduino

This is a simple Arduino sketch that was originally designed to experiment with arrays and the built-in timing functionality. I based it on the tutorial sample code http://www.arduino.cc/en/Tutorial/Knock
The system consists of a piezo sensor connected to an analog pin that listens for a knock from the user. The Arduino then stores the time the knock occurred in an array.
After a predefined time without further knocks occurring, the Arduino will ‘play back’ the knocks on a buzzer and LED in time to the original knocking pattern.

The device could be expanded to include a stepper motor or similar suitable output that would recreate the knocks exactly, just replace the output buzzer.
You could also use the piezo input sensor as the output buzzer by altering the code.

Step One: Materials
You will need:
  1. An Arduino UNO or compatible board.
  2. An LED and appropriate resistor (I used 220R).
  3. A piezo sensor.
  4. A 1M pull-down resistor.
  5. A piezo buzzer or alternative output device (see page one notes).
  6. A breadboard and wires.

Step Two: Assemble

The configuration of the device is fairly simple.

knock_back_bb

  1. Connect the LED to pin 9 (via the resistor) and GND.
  2. Connect the output buzzer to pin 8 and GND.
  3. Connect the knock senzor to analog pin 0 AND GND.
  4. Connect your 1M resistor to the positive wire of the knock sensor and GND. This is used as a pull-down resistor.

Note: Be sure to check that my resistor recommendations are correct for the components you are using, including the lack of resistors on the two piezo buzzers.

Step Three: The Sketch

Upload the following to your Arduino.

Knock Back Sketch

Step Four: Knock it ’till you’ve tried it”

If everything went well, your “Knock Back” device should be ready to test. Simply tap a pattern into the knock sensor, wait 2 seconds and watch it replay the pattern.See the video below for an example.