loading
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:

Hardware:
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)

Software:
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.

<p>I am having trouble finding the &quot;sketchbook&quot; folder (which has the proper &quot;Libraries&quot; folder, where you are supposed to copy the Arduino Library) within the main Processing folder.... Does anyone have a direct file path (starting at the main Processing folder) that maps out all the other folders one must navigate through in order to find &quot;sketchbook&quot; folder and then subsequently the correct &quot;Libraries&quot; folder????</p>
<p>hope this helps you.</p>
<p>how do i change the transition time b/w colors???</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 so much...</p>
<p>It works. Thanks for the great work. But may i know how do i store it into the arduino. because everytime it finish, I've to click play on processing in order to work again.</p>
<p>can you help me please , i'am stuck in this</p><p> Go to File -&gt; Examples -&gt; Firmata -&gt; StandardFirmata, and press the Upload button on the Arduino SE (see image 2).</p><p>and i don't found upload !!!!!!</p>
<p>im pretty new to this side of programming i followed all the instructions and im getting a pretty big error could some please help me ive been struggling with what to do next ive searched all over and im sure its something simple here is the error </p><p>Arduino: 1.6.1 (Windows 7), Board: &quot;Arduino Uno&quot;</p><p>BeatWrite.ino:20:1: error: 'import' does not name a type</p><p>In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:24:0,</p><p> from BeatWrite.ino:20:</p><p>BeatWrite.ino:20:28: error: expected unqualified-id before 'true'</p><p>BeatWrite.ino:22:1: error: 'import' does not name a type</p><p>BeatWrite.ino:23:1: error: 'import' does not name a type</p><p>BeatWrite.ino:25:1: error: 'Minim' does not name a type</p><p>BeatWrite.ino:26:1: error: 'AudioPlayer' does not name a type</p><p>BeatWrite.ino:27:1: error: 'BeatDetect' does not name a type</p><p>BeatWrite.ino:28:1: error: 'BeatListener' does not name a type</p><p>BeatWrite.ino:29:1: error: 'Arduino' does not name a type</p><p>BeatWrite.ino: In function 'void setup()':</p><p>BeatWrite.ino:38:9: error: 'Arduino' was not declared in this scope</p><p>BeatWrite.ino:38:26: error: 'println' was not declared in this scope</p><p>BeatWrite.ino: In function 'void draw()':</p><p>BeatWrite.ino:42:13: error: 'background' was not declared in this scope</p><p>BeatWrite.ino:43:9: error: 'fill' was not declared in this scope</p><p>BeatWrite.ino:44:4: error: 'beat' was not declared in this scope</p><p>BeatWrite.ino:45:1: error: 'arduino' was not declared in this scope</p><p>BeatWrite.ino:45:30: error: 'Arduino' was not declared in this scope</p><p>In file included from BeatWrite.ino:20:0:</p><p>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:40:14: error: expected unqualified-id before numeric constant</p><p> #define HIGH 0x1</p><p> ^</p><p>BeatWrite.ino:45:38: note: in expansion of macro 'HIGH'</p><p>BeatWrite.ino:48:4: error: 'beat' was not declared in this scope</p><p>BeatWrite.ino:49:1: error: 'arduino' was not declared in this scope</p><p>BeatWrite.ino:49:31: error: 'Arduino' was not declared in this scope</p><p>In file included from BeatWrite.ino:20:0:</p><p>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:40:14: error: expected unqualified-id before numeric constant</p><p> #define HIGH 0x1</p><p> ^</p><p>BeatWrite.ino:49:39: note: in expansion of macro 'HIGH'</p><p>BeatWrite.ino:52:4: error: 'beat' was not declared in this scope</p><p>BeatWrite.ino:53:1: error: 'arduino' was not declared in this scope</p><p>BeatWrite.ino:53:31: error: 'Arduino' was not declared in this scope</p><p>In file included from BeatWrite.ino:20:0:</p><p>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:40:14: error: expected unqualified-id before numeric constant</p><p> #define HIGH 0x1</p><p> ^</p><p>BeatWrite.ino:53:39: note: in expansion of macro 'HIGH'</p><p>BeatWrite.ino:56:1: error: 'arduino' was not declared in this scope</p><p>BeatWrite.ino:56:30: error: 'Arduino' was not declared in this scope</p><p>In file included from BeatWrite.ino:20:0:</p><p>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:41:14: error: expected unqualified-id before numeric constant</p><p> #define LOW 0x0</p><p> ^</p><p>BeatWrite.ino:56:38: note: in expansion of macro 'LOW'</p><p>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:41:14: error: expected unqualified-id before numeric constant</p><p> #define LOW 0x0</p><p> ^</p><p>BeatWrite.ino:57:39: note: in expansion of macro 'LOW'</p><p>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:41:14: error: expected unqualified-id before numeric constant</p><p> #define LOW 0x0</p><p> ^</p><p>BeatWrite.ino:58:39: note: in expansion of macro 'LOW'</p><p>BeatWrite.ino:59:18: error: 'textSize' was not declared in this scope</p><p>BeatWrite.ino:60:14: error: 'width' was not declared in this scope</p><p>BeatWrite.ino:60:23: error: 'height' was not declared in this scope</p><p>BeatWrite.ino:60:31: error: 'text' was not declared in this scope</p><p>BeatWrite.ino: In function 'void stop()':</p><p>BeatWrite.ino:72:1: error: 'song' was not declared in this scope</p><p>BeatWrite.ino:74:1: error: 'minim' was not declared in this scope</p><p>BeatWrite.ino:76:1: error: 'super' was not declared in this scope</p><p>BeatListener.ino: At global scope:</p><p>BeatListener.ino:1:31: error: expected initializer before 'AudioListener'</p><p>Error compiling.</p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p>
Also had the &quot;the package &quot;cc&quot; does not exist issue. To fix -- In the Processing Editor, select &quot;Sketch&quot; &gt; &quot;Add File&quot;, then just select the &quot;Ardunio.jar&quot; file. Should work! <br> <br>I also got &quot;ArrayIndexOutOfBoundsException&quot; -- To get this fixed; <br> <br>Changed line 35 from; <br> arduino = new Arduino(this, Arduino.list()[1], 57600); <br>To; <br> arduino = new Arduino(this, Arduino.list()[0], 57600); <br> <br>And then it works!! :) <br>
<p>thanks.</p>
<p>Thank you!!</p>
<p>Thank you!</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>Can we use arduino uno for this project?</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>Hey, I had the same prob! To fix wire everything up without the resistors. Like this: </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>Hey, I had the same prob! To fix wire everything up without the resistors. Like this:</p><p></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>Guyz I have problem saying Null Pointer Exception</p><p>can anyone help me?</p><p>Thanks a Lot</p>
<p>i did everything but i got this error</p><p>&quot;no libraries found for ddf.minim&quot;</p><p>&quot;no libraries found for ddf.minim.analysis&quot;</p><p>please help me out.</p>
<p>trying to do this for a class and the beatwrite seems to be working, the tiny light on the arduino is flashing on beat but we cannot get it to transfer to the LED pins. we have checked our wiring and it seems to be correct. has anyone troubleshoot similar issues?</p>
<p>I have and error and its all ports are busy :/<br>any solutions?</p>
<p>Marika28 the Solution is to </p><p>First of all click &quot;Sketch&quot; then click &quot;Import Library&quot; then click &quot;Add Library&quot; then scroll down till you find &quot;Minim&quot; and click &quot;Install&quot;</p><p>I had the same problem as you</p>
<p>Does anyone know how to fix this problem?</p><p>&quot;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.&quot;</p><p>Where is the ddf.minim folder?</p>
<p>I got all the way to the point where I just had to run the file but it's telling me that it cannot find Minim and Arduino and that sort of stuff (the variables)</p>
<p>Thank you it's works perfectly by change:</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>HOW DO YOU GET THE LEDS TO LIGHT UP??????</p>
<p>Wow calm down</p>
<p>If someone could help me I would be so unbelievably grateful. I did all the steps, but I get an error that says, &quot;Cannot find a class or type named BeatListener&quot;</p><p>Please can someone help me. On one of the pictures ^^^ There are two tabs: BeatWrite and BeatListener. I only have BeatWrite. Can someone please help me!!!</p>
It worked after editing the Beatwrite code as previous comments have indicated. Thanks everyone!
<p>Hi. Does anyone know how I can extend the length of time each LED is on for? I am trying to hook the outputs to a relay module and feed it to a traffic light. The period of each pulse is way too fast at the moment and I am looking to reduce it. </p>
<p>I got <a href="https://www.youtube.com/watch?v=ianfNfxamc8" rel="nofollow">this</a> up and running this weekend. Works pretty well with this relay board: </p><p>http://www.sainsmart.com/4-channel-5v-relay-module-for-pic-arm-avr-dsp-arduino-msp430-ttl-logic.html</p><p> (although sometimes you need to tweak the delays for different music styles). The main changes I made to the code were:<br><br>- beat.setSensitivity(800);<br><br>- added a delay function<br><br>- added a delay(200) within each of the beat detect if statements<br><br>- the relay is active low, so I reversed the output logic levels<br><br>Here is my full code: http://pastebin.com/fhZYyh6P</p>
<p>Framebuffer error (framebuffer unsupported), rendering will probably not work as expected Read http://wiki.processing.org/w/OpenGL_Issues for help.</p><p>OpenGL error 1280 at bot beginDraw(): invalid enumerant</p><p>java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1</p><p>at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)</p><p>at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103)</p><p>at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:206)</p><p>at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172)</p><p>at javax.media.opengl.Threading.invoke(Threading.java:191)</p><p>at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:541)</p><p>at processing.opengl.PJOGL.requestDraw(PJOGL.java:688)</p><p>at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1651)</p><p>at processing.core.PApplet.run(PApplet.java:2256)</p><p>at java.lang.Thread.run(Unknown Source)</p><p>Caused by: java.lang.ArrayIndexOutOfBoundsException: 1</p><p>at BeatWrite.setup(BeatWrite.java:56)</p><p>at processing.core.PApplet.handleDraw(PApplet.java:2361)</p><p>at processing.opengl.PJOGL$PGLListener.display(PJOGL.java:862)</p><p>at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:665)</p><p>at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:649)</p><p>at javax.media.opengl.awt.GLCanvas$10.run(GLCanvas.java:1289)</p><p>at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1119)</p><p>at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:994)</p><p>at javax.media.opengl.awt.GLCanvas$11.run(GLCanvas.java:1300)</p><p>at java.awt.event.InvocationEvent.dispatch(Unknown Source)</p><p>at java.awt.EventQueue.dispatchEventImpl(Unknown Source)</p><p>at java.awt.EventQueue.access$200(Unknown Source)</p><p>at java.awt.EventQueue$3.run(Unknown Source)</p><p>at java.awt.EventQueue$3.run(Unknown Source)</p><p>at java.security.AccessController.doPrivileged(Native Method)</p><p>at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)</p><p>at java.awt.EventQueue.dispatchEvent(Unknown Source)</p><p>at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)</p><p>at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)</p><p>at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)</p><p>at java.awt.EventDispatchThread.pumpEvents(Unknown Source)</p><p>at java.awt.EventDispatchThread.pumpEvents(Unknown Source)</p><p>at java.awt.EventDispatchThread.run(Unknown Source)</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>This continues to pop up when I try to run to program. I'm running it on mac. How do I fix it?</p>
<p>you might need to install the Arduino library for Processing. </p>
<p>hi!</p><p>Can i use laser instead of leds?</p>
<p>CAN I ATTACH MICROPHONE FOR INPUT</p>
Hello, everyone!<br>I need your help!<br>When i run the BeatWrite I got this output<br>BeatWrite show nothing<br>Who knows what the problem?
<p>I'm having a problem on where do i extract the arduino library for processing .<br>When i run the processing there's an error telling that there's no cc.arduino in your library . Can someone show me on where to extract the arduino library . Step by step . Thanks for those who's willing to help me . Hoping for your replies! </p>
<p>You can just go to Sketch/Import library/Add library and then search for Arduino, click install, and there you go</p>
<p>Worked great for me, thanks for the awesome tutorial! Fun little project that I plan on expanding into future projects. The only comment I have is that I was running into some problems communicating with the arduino initially. </p><p>In the Beatwrite code be sure to edit the following line of code: </p><p> arduino = new Arduino(this, Arduino.list()[2], 57600);</p><p>The number in brackets (2 in this example) is the com port that the arduino is on. I'm running a mac, so it wasn't listed as com 1,2,3 like it is one a windows machine. I simply used trial and error starting at 0 and eventually it worked when I tried 2. After I got that sorted out, it worked great. </p><p>I also attempted to play a .m4a audio file and the program crashed. I'm not sure if there's another format that can be used, but I plan on doing further research. </p>
<p>Thank you, this was really helpful and I was able to make it work with your edit. </p>
<p>I got it working but is there any ideas on getting it to play with live streaming audio from either a player or line in</p>
<p>Have you had any luck with this? I'd love to have to do that as well. Maybe use an a microphone to pick up the surrounding audio and have it analyzed by processing? That seems crude, but it's what comes to mind at the moment. </p>
<p>I everybody! I keep getting an error that the serial port is on bluetooth even though we have it on usb...did anybody run into this issue as well? </p>
<p>yes i did, the way I fixed it was by changing the line </p><p>arduino = new Arduino(this, Arduino.list()[1], 57600);</p><p>on the processing program to 3 so it looks like this</p><p>arduino = new Arduino(this, Arduino.list()[3], 57600);</p><p>this may be different for you but you can find out by going to arduino program and selecting the menu tools - serial port and then looking to see what number down the list /dev/cu.usbmodem1411 is but when you are counting ignore the /dev/tty. one as these are a different type of port</p><p>And if this doesnt work message me</p><p>Hope this helps</p><p>MacMan</p>
Hey guys, I fixed the &quot;the package &quot;cc&quot; does not exist. you might be missing a library.&quot; error! ITS SUPER SIMPLE! Just go to /libraries/arduino/library/ and rename the Arduino.jar to arduino.jar with a lowercase :)

About This Instructable

493,203 views

267 favorites

License:

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