The LED flashing circuit makes use of the Minim audio library and the Arduino program Processing to analyze sound, producing a response based on a snare drum hit, a bass drum hit, and a hi-hat hit from the percussion of the audio file.
Step 1: Parts/Tools Needed
1. An Arduino microcontroller board. There are many versions of the Arduino, but I would recommend the Arduino Duemilanove. You can buy one online for around $20.
2. Three LEDs (different colors preferred, so you can see the difference in beats easier - I used a red, yellow, and green LED)
3. Three resistors (depending on your LEDs, the resistor value will be different - check the ratings on the LEDs to see what resistance corresponds to their maximum brightness, without burning them out)
4. A solderless breadboard
5. Some wire, to use as leads from the Arduino to the LEDs/resistors on the breadboard
6. A computer
7. A USB cable (A to B)
1. Arduino Software Environment
2. Processing Software Environment
3. The "arduino" library for Processing
4. The BeatWrite / BeatListener code from the minim JavaSound library examples
Download links for the software will follow in Step 3.
Step 2: Build the Circuit on the Breadboard
1. Run a wire from the digital GND port of the Arduino to the negative outer rail of the breadboard, as shown in image 1.
2. Place your three resistors (I used 1kilo-ohm resistors for this example, which matched my LEDs well enough) in an evenly-spaced fashion on the inner rails of the breadboard. Note that on a breadboard, a line runs length-wise, halfway down the middle. This separates the left inner rails from the right inner rails, so you can connect more components. Position the resistors so that they bridge the gap between the inner rails, as shown in image 2.
3. Place the LEDs right next to the right side of the resistors, with the anode (the longer end) in the slot right next to the resistor, and the cathode (the shorter end) into the slot that is offset to the resistors by 1 slot, as shown in image 3 (see image 4 to see the difference between an anode and a cathode).
4. Run wires from the cathode rail of the LEDs to the ground outer rail, as shown in image 5.
5. Run wires from the anode side of the resistors to digital pins 12, 8, and 2 on the Arduino to complete the circuit, as shown in image 6 and 7.
Now that we have our circuit made, it's on to the programming.
Step 3: Program Your Arduino
1. Connect the Arduino to your computer with your A to B USB cable (your computer should install its driver automatically) - see image 1.
2. Download the Arduino Software Environment from here and extract it to a folder (no installation required, just keep the folder in a safe place).
3. Download the Processing Software Environment from here and extract it to a folder near your Arduino SE folder.
4. Download the Arduino library for Processing from here, and copy it into your Processing/libraries folder.
5. Run the arduino.exe program in your Arduino SE folder.
6. Go to File -> Examples -> Firmata -> StandardFirmata, and press the Upload button on the Arduino SE (see image 2).
7. Wait a few seconds, until your RX/TX LEDs on your Arduino stop blinking (which means the Firmata firmware is installed).
8. Download and unzip the attached folder of code below (BeatWrite.zip).
9. Copy an .mp3 file into the "data" folder of the unzipped BeatWrite folder.
10. Open Processing (processing.exe), then open the BeatWrite.pde file in the BeatWrite folder.
11. Edit the line of code "song = minim.loadFile("freebird.mp3", 2048);". Instead of using "freebird.mp3", use the filename of your mp3.
12. Hit the Run button on the top-left (see image 3).
Sit back, and enjoy the light show!
Step 4: How It Works / Customizing the Script
Many thanks to the Minim team for providing a BeatDetect manual with plenty of examples. This LED tutorial is a hardware extension of this software example.
Step 5: How It Should Look
Have fun with your new Arduino BeatDetect circuit!