This is a guide to make an LED flashing circuit that "beats" to an mp3 file on your computer, which can add an awesome effect to any sound-related device, or even your room (if you extend the concept with LED drivers or plenty of resistors/transistors).

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

Here is what you'll need to make the LED beat flashing circuit:

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

In order to have the Arduino access the LEDs, you have to build a small circuit on a solderless breadboard. The breadboard has two parts: the inner rails (which run width-wise) and the outer rails (which run length-wise). The rails are electrically connected along their lines, so you can connect components without actually soldering them together. Here is how to make our simple circuit:

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

Programming the Arduino is pretty simple. Through a couple of small programs, your simple LED circuit will be dancing to the beat in no time.

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

The reason this program works is due to the minim JavaSound library. This fancy library comes with Processing, and can do plenty of cool things with analyzing audio signals. In our case, it uses the fast fourier transform of the audio signal from the mp3 to analyze certain frequencies, and lights an LED if certain ranges of frequencies go above the allotted "sensitivity" value. In order to change this sensitivity value, all you need to do is change the "beat.setSensitivity(100);" line of code in the BeatWrite program. Also, as I said before, you can definitely extend this concept to many LEDs on a large scale. This is just a small-scale example of the potential for this great library. Also, if you know more about your mp3 than just generic hi-hat, snare, and bass drum hits, you can use the isRange(int low, int high, int threshold) method to beat the circuit to other patterns in your music. The sky is the limit in terms of audio processing with Minim and BeatDetect.

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

Here is a video of when I first made the BeatWrite circuit (it looks a little different than the one we're building, but the concept is the same).

Have fun with your new Arduino BeatDetect circuit!
<p>Hi all, hoping for some insight here.</p><p>All connections appear to be correct on the Arduino (I'm using an Arduino Uno) and my mp3 has been copied into by BeatWrite Data folder, and the minim library is installed, but still can't troubleshoot these errors. Any thoughts?</p>
<p>Errors Read as:</p><p>==== JavaSound Minim Error ====</p><p>==== java.io.FileNotFoundException: 08 Hunger Of The Pine.mp3</p><p>=== Minim Error ===</p><p>=== Couldn't load the file 08 Hunger Of The Pine.mp3</p>
<p>The thing i'd focus on is &quot;FileNotFound&quot;... Did you do these steps below? Also: I'd try getting rid of spaces in your file name... i.e. rename your file without spaces, and then change your code to use that new &quot;non space&quot; name... Some times things don't like spaces in file names</p><p>&quot;9. Copy an .mp3 file into the &quot;data&quot; folder of the unzipped BeatWrite folder.</p><p>10. Open Processing (processing.exe), then open the BeatWrite.pde file in the BeatWrite folder.<br>11. Edit the line of code &quot;song = minim.loadFile(&quot;freebird.mp3&quot;, 2048);&quot;. Instead of using &quot;freebird.mp3&quot;, use the filename of your mp3.&quot;<br><br></p>
<p>try the following<br><br><a href="https://www.instructables.com/member/Isaack19" rel="nofollow">Isaack19</a><a rel="nofollow">Reply</a>a year ago</p><p>Works great! I used an Arduino R3 and it works fine. In processing, if you are missing libraries, go to &quot;Sketch &gt; Import Library &gt; Add Library&quot; and add &quot;Arduino (Firmata)&quot; and &quot;Minim&quot;. Also changing</p><p>&quot;arduino = new Arduino(this, Arduino.list()[1], 57600);&quot;</p><p>to:</p><p>&quot;arduino = new Arduino(this, Arduino.list()[0], 57600);&quot;</p><p>made it work.</p>
<p>I'm wanting to build a custom electric guitar with an Arduino brain inside the body, and led's on the outside that will light up when certain frequencies are passed to the output jack. Is there a way to route those frequencies into the Arduino instead of an mp3 file to light the lights?</p>
<p>guys I get and error that says </p><p>=== Minim Error ===</p><p>=== Couldn't load the file crazy bass mastered</p><p>Could not run the sketch (Target VM failed to initialize).</p><p>For more information, read revisions.txt and Help ? Troubleshooting.</p><p>why is it saying that?</p>
<p>Have you installed every library needed?</p>
<p>you have to put file extension with file name</p>
<p>hello, can you give me an exemple ? Because I have this problem :/ </p>
<p>go to sketch&gt;add file , it finally worked!</p>
<p>Hi All</p><p>Im very new to this but love this video and really want to make this work. I keep getting the following error message:</p><p>expecting SEMI, found 'song'</p><p>On this line:</p><p>song = minim.loadFile(&quot;123.mp3&quot;, 2048);</p><p>Can someone help please? Im sure this is probably a quick fix but im stumped!</p><p>Thanks </p>
<p>Copy the mp3 file into the data folder (locate your BeatWrite folder=&gt;data), then copy the name from the song make sure the .mp3 is copied too and replace it with the: song = minim.loadFile(&quot;123.mp3&quot;, 2048);, also make sure the *song*.mp3 is between the &quot; &quot;.</p>
<p> Works great! I used an Arduino R3 and it works fine. In processing, if you are missing libraries, go to &quot;Sketch &gt; Import Library &gt; Add Library&quot; and add &quot;Arduino (Firmata)&quot; and &quot;Minim&quot;. Also changing</p><p> &quot;arduino = new Arduino(this, Arduino.list()[1], 57600);&quot;</p><p>to:</p><p>&quot;arduino = new Arduino(this, Arduino.list()[0], 57600);&quot;</p><p>made it work. </p>
<p>thank you :D</p>
<p>thank u!! It works fine now :D</p>
<p>Thank you!!</p>
<p>Is it possible to replace a rgb led strip for single led?</p>
<p>Is it possible to use the same code and instead of using it to light up single LEDs, we can fire up multiple LEDs like in a series or as a structure? just a basic design to make all LEDs light up for different &quot;beats&quot;.</p>
<p>would it be possible to make a cube of LEDs 3 by 4 on each side? </p>
<p>I am trying to get the different layers to flash individually for each output, using the basic 3x3x3 LEDCube circuit, probably harder than it looks :/</p><p>one question: would assigning three pins as output for kick/snare/hit have the same effect as having one output, considering a 3x3x3 cube requires 9 inputs to each column of LEDs and three more for arranging the transistors to each planar layer of LEDs?</p><p>I've got it running fine with three LEDs</p>
<p>Hi! thanks for this tutorial, very interesting and there's not much on this. I just have a couple of questions! First what do kickSize/snareSize/hatSize do? and how do I use inRange? what do the values in inRange represent?</p><p>Thankyou!!</p>
<p>guys am new here... i liked dis video. but i want to join a series of led lights.... lik dis one.. pls help me</p>
<p>Hi, I just did everything that's told on the instructions, I built the circuit, BeatWrite runs without errors but leds won't light up. Can anyone help me?</p>
<p>You may need to change the 0 in this line to the com port number your Arduino is using:</p><p>&quot;arduino = new Arduino(this, Arduino.list()[0], 57600);&quot;</p>
<p>No you have to change the whole word like this:</p><p>arduino = new Arduino(this, &quot;com4&quot;, 57600);</p>
<p>&quot;arduino = new Arduino(this, Arduino.list()[0], 57600);&quot;</p><p>it is [0] or [1] for even or odd parity</p>
<p>Did you get this issue solved?</p>
<p>Guyz I have problem saying Null Pointer Exception</p><p>can anyone help me?</p><p>Thanks a Lot</p>
<p>Hey did you figure out what the problem was? I am having the same error :(</p>
<p>im having the same problem. did you figure out a solution? our arduino board is lighting to the beat but the LEDs are not and the wiring seems to be right.</p>
<p>What do you mean by the Arduino board is lighting to the beat? The RX LED on the Arduino?</p>
<p>Hey, I had the same prob! To fix wire everything up without the resistors. Like this:</p><p></p>
<p>Hey, I had the same prob! To fix wire everything up without the resistors. Like this: </p>
<p>have the exact problem. It loads on the arduino but does not show up on the LED lights, can someone please help</p>
<p>Hey, I had the same prob! To fix wire everything up without the resistors. Like this: </p>
<p>I have and error and its all ports are busy :/<br>any solutions?</p>
<p>I know it seems silly but change Cable connecting UNO to computer.<br>see physical connection on:<br><a href="https://www.arduino.cc/en/Guide/Troubleshooting#upload" rel="nofollow">https://www.arduino.cc/en/Guide/Troubleshooting#up...</a><br></p>
<p>If everything (all the code) seems to be running fine, but your LEDS just wont light up</p><p>try changing the line to </p><p>arduino = new Arduino(this, &quot;/dev/cu.usbmodem1411&quot;, 57600);</p><p>where the part inbetween the double quotes is your arduino's serial. This can be found on the bottom right of any arduino code page </p>
<p>what about arduino? is code upload interval wise(buffer of course) or compile first and upload the whole rhythm at the start? </p><p>-secondly how about if we close the processing and music then what? Arduino will continue to blow the led according?</p>
<p>Sorry guys...just wondering where and how can I change</p><p>==&gt; isRange(int low, int high, int threshold) method as mentioned above??</p>
<p>Night club strobe light - Strobe flash and club disco light that sync with your music beat. Party on!</p>Description<p>It provides a FREE handy strobe light to you right in your pocket! It will listen to the music around you and blink the flash on your device, just like a strobe light. Not just that, the phone screen will become a disco light, one might say, strikes at your music beats! That&rsquo;s NOT all. Swipe your screen and it will give you several majestic hallucinations, sync with your music, of course. This app is just perfect for your party group, large or small, or even for enhancing your personal musical experience. Bring your phones together and party is just one tap away!<br><br>**NOTICE** <br>Playing media via bluetooth devices will be disabled during using session of the app due to the low quality sound limited by Apple.<br><br>**FEATURES**<br>- Strobe light syncs with your music<br>- Disco light syncs with your music<br>- Hallucination effects, sync with your music<br>- Sensitivity adjustment by quick or accurate mode, with good visual presentation. <br>- Torch light support, for..ehhm&hellip; finding objects you drop on the floor for example.<br>- Listen to music from around you or right from your phone<br>- Futuristic design, smooth animation<br>**HOW TO USE**<br>- Tap the screen light button (on the left) to activate disco light and screen light effects.<br>- Tap the strobe light button (on the right) to activate strobe light effect. Tap again to switch to torch light mode.<br>- You will see the music reflects on the slider bar in color. Once the color bar exceed the pointer on the slider, flash light will strike. This is how you control sensitivity.<br>- For quick configuration, just tap on the marks on the slider to adjust the sensitivity. Move your finger on the slider (you don&rsquo;t have to place your fingertip exactly on the pointer) for more accurate result.<br>- Swipe left or right to change screen effect and hallucinations.</p><p>Link ios: <a href="https://itunes.apple.com/us/app/night-club-strobe-light-strobe/id1128598578?ls=1&mt=8" rel="nofollow">https://itunes.apple.com/us/app/night-club-strobe-...</a></p><p>link preview: https://www.youtube.com/watch?v=WKEbaaBdtd0</p>
<p>what did I do wrong here? there are so many errors</p><p>it also keeps saying that all of the libraries but processing.serial haven't been downloaded, but I thought that the minim library came with Processing, so I'm not sure what the problem is. Please get back to me as soon as possible!</p>
<p>now it says that the ddf.minim library and the sun.audio library don't match, and also the the sun.audio library can't be found. is there something else I need to download?</p>
<p>Can some one please help :( I have no idea what this is and I've been at this for hours. It says &quot;unexpected token&quot; and it has line 19 highlighted &quot;Minim.minim;&quot; </p>
<p>You didn't install the minim library. Minim comes included by default on Processing 2 but not Processing 3.</p><p>To install it on processing 3, click sketch &gt; import library &gt; add library, then search for minim and click install.</p><p>Hope this helps</p>
<p>Has anyone tried to build it on Android Mode with Android SDK? I have tried but still stuck with error as below.</p><p><em><strong>[dx] </strong></em></p><p><em><strong> [dx] PARSE ERROR:</strong></em></p><p><em><strong> [dx] unsupported class file version 52.0</strong></em></p><p><em><strong> [dx] ...while parsing ddf/minim/javasound/BasicMetaData.class</strong></em></p><p><em><strong> [dx] 1 error; aborting</strong></em></p><p><em><strong>BUILD FAILED</strong></em></p><p><em><strong>C:\Program Files (x86)\adt-bundle-windows-x86-20140321\sdk\tools\ant\build.xml:888: The following error occurred while executing this line:</strong></em></p><p><em><strong>C:\Program Files (x86)\adt-bundle-windows-x86-20140321\sdk\tools\ant\build.xml:890: The following error occurred while executing this line:</strong></em></p><p><em><strong>C:\Program Files (x86)\adt-bundle-windows-x86-20140321\sdk\tools\ant\build.xml:902: The following error occurred while executing this line:</strong></em></p><p><em><strong>C:\Program Files (x86)\adt-bundle-windows-x86-20140321\sdk\tools\ant\build.xml:283: null returned: 1</strong></em></p><p><em><strong>Total time: 26 seconds</strong></em></p>
<p>It all worked out fine for me but the LEDs are not as in sync as I was hoping them to be. I hope to make improvements on the software myself. Has anyone else tried this?</p>
<p>How to fix this?</p><p>No library found for ddf.minim</p><p>No library found for ddf.minim.analysis</p><p>Libraries must be installed in a folder named 'libraries' inside the 'sketchbook' folder.</p>
<p>Put the arduino library in <br>Documents&gt;Processing&gt;libraries, and if it doesn't work use <br>processing v2, download it from here : </p><p><a href="https://processing.org/download/?processing" rel="nofollow">https://processing.org/download/?processing</a></p><p>(Run processing at least once before doing that to create the Processing folder in Documents)</p>

About This Instructable




More by Hyrulian:How to Make LEDs Flash to Music with an Arduino 
Add instructable to: