LED Dance Room

97,973

175

108

This is a guide for building an Arduino-based LED music visualizer, AKA a totally sweet digital dance room.

There are various guides around instructables about pure circuit visualizers, but those are generally some kind of amplifier to make the lights pulse and change intensity in response to the power conveyed in the audio signal. I wanted something more along the line of multiple strobes responding to different frequencies of music. The end result is the mutant stepchild of this and this and a little of this, but it is totally worthwhile.

The actual audio signal gets read in from the microphone jack on the computer, so it can either accept its own sound fed back or the sound from an iPod / Rock Band / karaoke / whatever you crazy kids can dream up.

Yay new music! Courtesy of DoKashiteru and the Creative Commons, I bring you an uncensored video of the system in action:


Step 1: Parts / Tools

Parts:
LEDs - Obviously. I bought really bright 10mm ones in varying colors in bulk from eBay, but you can find them on Digikey or Mouser. Higher millicandela ratings are better, especially if you want these to illuminate anything and not just be a spot of color. Shop around to find a good deal.

Resistors - One for each LED. Mine required 470 ohms, but make sure you check the ratings on your LEDs so that you get as much light as possible without burning them out.

Solderless breadboad - For all the circuitry.

Arduino - The computer/circuit interface. An awesome little board. Buy it online.

Wire - Lots of solid-core wire. I needed a lot, fast, so I ended up cleaning out my local RadioShack of this stuff, but you should be able to find it a lot cheaper. Having two strands held together like this is extremely useful, as you'll see later.

Computer - Where the actual computation takes place. Yes, this may be slightly overkill to flash a few lights, but as we inevitably end up playing our dance music from a laptop anyway it worked out just fine.

Power supply - The LEDs will likely draw more power than the arduino can provide, so we're going to be powering them externally and switching them with transistors. You should have a bunch of these lying around from old electronics, or you can find them at thrift stores. See the planning page for what voltage / amperage you need.

NPN transistors - We're using these as current amplifiers / switches. A little current drawn from the arduino controls a lot of current drawn from the power supply that runs through the LEDs. Find them online or at RadioShack.

Soldering iron - Pretty self-explanatory.

Speakers / audio splitter / male-male audio cable - Speakers for sound, splitter and cable to feed the signal from the headphone output to the speakers and microphone jack.

Software:
Arduino - Download the arduino software environment from here.

Processing - Processing talks well with arduino, and has some awesome libraries built in. Download it from here. Make sure you have the latest version of the Minim audio processing library from here. You may also need to get the 'arduino' library to get them to communicate - get it from here and stick it in your Processing/libraries folder.

Step 2: Circuit Design

An overall view of the circuit we're building. The two strands of the wire are connected to the high and low voltages, and each LED/resistor pair bridges them to light up. The low voltage strand is actually connected to ground through a transistor so that we can control the amount of current that flows (and therefore the brightness of the LEDs).

Step 3: Planning!

The most important step is to plan out what colors you want, and where. The ceilings in my dorm are best described as "waffle-shaped," with square indentations tiling the surface. These made a very natural grid to lay out the colors, but you'll need to come up with your own plan. You can figure on up to 8 or so LEDs to a single control strand, meaning that those 8 will turn on and off simultaneously.

With a layout all drawn up, now we need power calculations. Check the datasheets for your LEDs to figure out the forward voltage and current. Mine have a voltage drop of ~3.5 volts and have a maximum current of 20 milliamps. As I had a 12 volt power supply lying around, we can do a little simple circuit math using Ohm's Law (V=IR): (12 - 3.5) = 0.02 * R --> R = 425 ohms. For simplicity we round that to 470 ohms. Most 5mm LEDs will have voltage drops around 2 volts and current ratings around 15 milliamps, but check so that you don't burn them out. Remember: the light intensity is proportional to the current, so use a bigger resistor to limit the current if they are too bright. Also make sure the power supply can handle all this current - some small ones are only rated to a few hundred milliamps, meaning you can only power 10-20 LEDs in parallel like we are.

Step 4: Prepare LEDs and Wire

It's a lot easier to attach the LEDs to the wires if we first solder them together with the resistors. Cut both the negative (shorter) lead of the LED and one side of a resistor about in half, then solder them together. Once this is done, bend the positive lead and the resistor outwards so that the LED sticks up a little. See the picture for a much clearer explanation.

Next, lay out all the wire and make sure you have enough for each strand to reach. Measure out and mark where each LED needs to go. Once again, the explanation for the actual attachment is best given by the picture. Solder the LEDs to the wire, making sure to keep the polarities consistent - all the positive leads to one wire, and all the negative leads to the other. Once you've finished, test the strands BEFORE you put them up - connect the wires to your power supply or a 9 volt battery to make sure all the lights turn on.

Next, put all the wires up! In my case, this involved lots and lots of white gaffer tape and a standing on chairs. Make sure the free ends all come together at one location, where we're going to put the breadboard, arduino, and computer. I also put little origami globes over the LEDs to diffuse the light - just cut small slits radially outward from the hole in the balloon to make four tabs and it will slip on nicely. See the picture on the previous page for the effect. Bonus points if the globes are made from old lecture notes.

Step 5: Build the Circuitry

There's really not much more to say. Connect the positive and negative leads from your power supply to the power rails on your breadboard, and connect the arduino ground pin to the same negative rail. See the picture for a good layout system. Test that everything is working by removing the leads from the arduino (shown in blue, black, and red below) and connecting them to the positive power rail. Current will flow through the transistors and allow the LEDs to turn on (if everything is connected properly). Put these back how they should be and connect the arduino to your computer with a usb cable.

To set up the sound system, plug the speakers and the male-male cable into the splitter. Send the other end of the male-male cable into the microphone jack on your computer. Again, this is slightly overkill if you're only going to play sound from your computer (especially if you can figure out how to use jack) but this way the system can flash to Rock Band or karaoke or anything else that can output on a 3.5mm audio jack.

Make sure your microphone is working - plug the splitter into any audio source, then open up a sound recording program to see if you're registering a signal. Oftentimes the microphone can be muted, so if you have problems that's the first place to look.

Step 6: Code Code Code

Open up the arduino software environment, and upload the StandardFirmata example sketch to the board. The sketch will allow you to control the arduino over a serial interface, meaning arbitrary code on the computer can control the lights we just hooked up.

The code that actually processes the audio signal is (conveniently) a Processing sketch. It is based around the awesome BeatDetect library in the minim library. The BeatDetect class computes the Fourier transform of the audio signal, and keeps track of the mean and variance of each of the coefficients for the last few seconds. If the value in any of the FFT bins exceeds the variance, a beat is detected and the light associated with that frequency will turn on. </technical>. What this means is that each strand of LEDs will correspond to a different frequency of music - one strand will flash to bass beats, another to snare hits, another to high vocal notes, and so forth, for 26 different frequencies.

Download the attached Processing sketch from below, and modify the ledPins array on line 10 to reflect your own setup. The first pin number corresponds to the lowest frequencies. Once that's done, you're finished! Plug the audio splitter into your headphone jack, start the sketch, and start playing some music. If everything works as expected, a waveform visualizer will pop up and the lights will being flashing. Enjoy!

Step 7: Troubleshooting

The main problems you're likely to encounter are getting Processing and the arduino to talk to each other. Make sure you install the arduino software - this will bring with it all the necessary serial libraries. You can find avoid problems with the circuit by testing as you go - test each LED, then each strand, then each transistor set. If all else fails go back to this to diagnose where the problem lies.

Now that I've managed to squash all the bugs from my own setup, I can't think of what they were off the top of my head. Post any problems you have, as I probably ran into them and have since forgotten.

Share

    Recommendations

    • Big and Small Contest

      Big and Small Contest
    • Toys Contest

      Toys Contest
    • PCB Contest

      PCB Contest

    108 Discussions

    0
    None
    MarcelloB

    3 years ago on Step 6

    I cannot get processing to communicate with my arduino!

    0
    None
    MarcelloB

    3 years ago on Introduction

    My led is not reacting with the sound at all I am just going directly to an led instead of using mosfets though

    0
    None
    aazahn

    5 years ago on Introduction

    I dont know if I'm doing something wrong, but I keep getting this error when trying to verify your code.
    Instructable:5: error: variable or field 'drawWaveForm' declared void
    Instructable:5: error: 'AudioSource' was not declared in this scope
    Instructable:2: error: 'import' does not name a type
    Instructable:3: error: 'import' does not name a type
    Instructable:4: error: 'import' does not name a type
    Instructable:5: error: 'import' does not name a type
    Instructable:7: error: 'Arduino' does not name a type
    Instructable:11: error: expected unqualified-id before '[' token
    Instructable:12: error: expected unqualified-id before '[' token
    Instructable:23: error: 'Minim' does not name a type
    Instructable:24: error: 'AudioInput' does not name a type
    Instructable:25: error: 'AudioPlayer' does not name a type
    Instructable:26: error: 'BeatDetect' does not name a type
    Instructable.pde: In function 'void setup()':
    Instructable:46: error: 'P2D' was not declared in this scope
    Instructable:46: error: 'size' was not declared in this scope
    Instructable:48: error: 'minim' was not declared in this scope
    Instructable:48: error: expected type-specifier before 'Minim'
    Instructable:48: error: expected `;' before 'Minim'
    Instructable:49: error: 'arduino' was not declared in this scope
    Instructable:49: error: expected type-specifier before 'Arduino'
    Instructable:49: error: expected `;' before 'Arduino'
    Instructable:51: error: 'ledPins' was not declared in this scope
    Instructable:52: error: 'Arduino' was not declared in this scope
    Instructable:52: error: expected unqualified-id before numeric constant
    Instructable:55: error: expected type-specifier before 'Minim'
    Instructable:55: error: expected `;' before 'Minim'
    Instructable:58: error: 'song' was not declared in this scope
    Instructable:60: error: 'beat' was not declared in this scope
    Instructable:60: error: expected type-specifier before 'BeatDetect'
    Instructable:60: error: expected `;' before 'BeatDetect'
    Instructable:63: error: 'in' was not declared in this scope
    Instructable:63: error: 'Minim' was not declared in this scope
    Instructable:64: error: 'beat' was not declared in this scope
    Instructable:64: error: expected type-specifier before 'BeatDetect'
    Instructable:64: error: expected `;' before 'BeatDetect'
    Instructable.pde: In function 'void draw()':
    Instructable:71: error: 'beat' was not declared in this scope
    Instructable:71: error: 'song' was not declared in this scope
    Instructable:72: error: 'AudioSource' was not declared in this scope
    Instructable:72: error: 'drawWaveForm' was not declared in this scope
    Instructable:74: error: 'beat' was not declared in this scope
    Instructable:74: error: 'in' was not declared in this scope
    Instructable:75: error: 'AudioSource' was not declared in this scope
    Instructable:75: error: 'drawWaveForm' was not declared in this scope
    Instructable:79: error: 'ledPins' was not declared in this scope
    Instructable:80: error: 'beat' was not declared in this scope
    Instructable:81: error: 'arduino' was not declared in this scope
    Instructable:81: error: 'Arduino' was not declared in this scope
    Instructable:81: error: expected unqualified-id before numeric constant
    Instructable:82: error: 'lastFired' was not declared in this scope
    Instructable:84: error: 'lastFired' was not declared in this scope
    Instructable:85: error: 'arduino' was not declared in this scope
    Instructable:85: error: 'Arduino' was not declared in this scope
    Instructable:85: error: expected unqualified-id before numeric constant
    Instructable.pde: At global scope:
    Instructable:96: error: variable or field 'drawWaveForm' declared void
    Instructable:96: error: 'AudioSource' was not declared in this scope

    1 reply
    0
    None
    ajayphoenix

    3 years ago on Introduction

    Its so coool.But it is acting different than yours.Mine is lighting up but just opposite of yours.My leds turn off instead of lighting up when it should.Why is that

    0
    None
    jweeks3

    5 years ago on Step 6

    I know this is kind of an old instructable but I was hoping I might get some help. Ive got everything installed and the visualizer window pops up, but the led's do nothing. It worked on another computer but doesn't want to run on my laptop. Any ideas?

    1 reply
    0
    None
    jelimoorejweeks3

    Reply 4 years ago on Step 6

    Well, @jweeks3, is the audio input set correctly on your computer? I ran intto the same problem before.

    0
    None
    jelimoore

    5 years ago

    Ok problem solved

    0
    None
    jelimoore

    5 years ago

    Ok so my input source is my internal mic on my Mac. Any help appreciated!

    0
    None
    jelimoore

    5 years ago

    Oh, PS I am using this for everything that comes out of my system

    0
    None
    jelimoore

    5 years ago

    This is so awesome!!

    0
    None
    cahill

    6 years ago on Introduction

    Im getting these errors:
    Stable Library
    =========================================
    Native lib Version = RXTX-2.1-7
    Java lib Version = RXTX-2.1-7
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalAccessError: tried to access class processing.core.PApplet$RegisteredMethods from class cc.arduino.Arduino$SerialProxy
    at cc.arduino.Arduino$SerialProxy.(Arduino.java:119)
    at cc.arduino.Arduino.(Arduino.java:168)
    at cc.arduino.Arduino.(Arduino.java:152)
    at sketch_121117a.setup(sketch_121117a.java:73)
    at processing.core.PApplet.handleDraw(PApplet.java:2103)
    at processing.opengl.PGL$PGLListener.display(PGL.java:2595)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:189)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:177)
    at javax.media.opengl.awt.GLCanvas$DisplayAction.run(GLCanvas.java:928)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:425)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:364)
    at javax.media.opengl.awt.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:827)
    at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:415)
    at javax.media.opengl.awt.GLCanvas.paint(GLCanvas.java:515)
    at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
    at sun.awt.RepaintArea.paint(RepaintArea.java:224)
    at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:308)
    at java.awt.Component.dispatchEventImpl(Component.java:4729)
    at java.awt.Component.dispatchEvent(Component.java:4481)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:648)
    at java.awt.EventQueue.access$000(EventQueue.java:84)
    at java.awt.EventQueue$1.run(EventQueue.java:607)
    at java.awt.EventQueue$1.run(EventQueue.java:605)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
    at java.awt.EventQueue$2.run(EventQueue.java:621)
    at java.awt.EventQueue$2.run(EventQueue.java:619)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:618)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Already called beginDraw().
    Exception in thread "Animation Thread" java.lang.RuntimeException: java.lang.IllegalAccessError: processing/core/PApplet$RegisteredMethods
    at processing.opengl.PGL.requestDraw(PGL.java:1021)
    at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1526)
    at processing.core.PApplet.run(PApplet.java:2006)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.IllegalAccessError: processing/core/PApplet$RegisteredMethods
    at cc.arduino.Arduino$SerialProxy.(Arduino.java:119)
    at cc.arduino.Arduino.(Arduino.java:168)
    at cc.arduino.Arduino.(Arduino.java:152)
    at sketch_121117a.setup(sketch_121117a.java:73)
    at processing.core.PApplet.handleDraw(PApplet.java:2103)
    at processing.opengl.PGL$PGLListener.display(PGL.java:2595)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:189)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:177)
    at javax.media.opengl.awt.GLCanvas$DisplayAction.run(GLCanvas.java:928)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:425)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:364)
    at javax.media.opengl.awt.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:945)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:646)
    at java.awt.EventQueue.access$000(EventQueue.java:84)
    at java.awt.EventQueue$1.run(EventQueue.java:607)
    at java.awt.EventQueue$1.run(EventQueue.java:605)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:616)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


    Does that mean something is wrong with my arduino library?
    Any help would be greatly appreciated

    1 reply
    0
    None

    Wow! That's one of the coolest things ever made with an Arduino! But I have also found this site which has detailed instructions on how to make a simple Arduino LED music visualizer. Its also pretty cool and dead simple: 

    http://gallactronics.blogspot.in/

    It can be of great help for amateur Arduino geeks. :P

    0
    None
    Spio

    6 years ago on Step 2

    Hi, great jobs. Could you tell me which are the transistors that you used before the leds?

    2 replies
    0
    None
    SecondTwoSpio

    Reply 6 years ago on Step 2

    Any NPN transistor that can handle the current will work - I think I used 2n2222s, but really anything should work.

    If you want to experiment with fading the LEDs or doing any kind of PWM you'll need to use something more heavy-duty - transistors and MOSFETs dissipate a lot of power while switching, and it's easy to burn up little signal-level transistors like the 2n222.

    0
    None
    SplotchyInk

    6 years ago on Introduction

    I was wondering if it was possible if there was a way to eliminate the computer and have the arduino react to a connected microphone. I kind of plan on making something similar but more portable. I dare say,even wearable.