loading

Hi! In this instructable we'll be building a good looking light that dances to all sounds and music, using simple components and some basic Arduino programming. It makes an awesome effect while standing on the desk when gaming, playing music, and anything else that makes sound really. Let's get going!

Step 1: Main Supplies

First things first: what kind of supplies do we need and what do they cost? Well, they are largely optional, and can be made with much improvisation. Even so, some key items are needed if you want to follow this guide:

Depending on the look you want, you might want to arrange the strips differently or diffuse the light in another way. This is where you can be creative. If you like my approach, I used the following items:

  • The tallest IKEA Droppar jar (IKEA Link)
  • A small length of PVC pipe.

All things considered I spent around 30$, where the LED strips were by far the most expensive part.

Step 2: Powering the Components

The star of the show is the sound detector module. This will provide an analog signal to the Arduino, which we can use to (hopefully) cleverly light the RGB lights. To be able to do this, we need to power both devices. Luckily they both require a 5 volt input. I am using a step down module to step down from 12 volts to 5 volts, but it would be easier to use a 5 volt power source directly. Wire the VIN on the Arduino and on the sound detector board to the positive input. Then wire the GND on the Arduino and the detector to the negative. Look at the black and the red wires on the attached schematic. We also need to hook the positive and negative input on the LED-strip to the power source.

Step 3: Detector & Strips

After having connected all three parts to the power, we need to connect them to eachother.

The sound detector module will communicate with the Arduino over the analog input pins. I will be using pin number 0, but which one does not matter.

The LED strips need a digital pulse to be able to understand which LED we want to address. Hence we need to connect a digital output pin to the Arduino nano. I will using pin number 6.

Awesome, now we are mostly done with the electronics!

Step 4: Uploading the Code

The most important part of this build will arguably be the code. It can change this build from pretty cool to insanely awesome. You can find the code i used here (github link). The main principle is to map the analog value we get from the sensor, to an amount of LEDs to show.

We can do this using the map function. This will let us display a certain amount of LEDs given an input, but nothing more than that. Doing only this might give you a jittery and flickering light. I decided to operate on the average of the llast X amount of readings to create a more sane and smooth transition. I also did some more advanced tracking of the song/sound intensity based on averages, to let the light change colors when the song enters a peak.

I will answer questions about the code if you have any, it's far from done, and contributions are welcome!

Step 5: Did Anyone Say Stuffing?

With all the code and the components done, it is assembly time. The PVC is obviously hollow, and we will take advantage of that by stuffing the electronics on the inside. We'll cut a slit in the PVC pipe to let us slide the strip out without obstructing the flush surface of the PVC hole. After that, we can glue the LED-strip to the PVC pipe. Some have asked me why I used hot glue, and not only the adhesive on the back of the strip. It's simply because my experience with it is that it will hold fine on really clean and straight surfaces, but on a curvature like this it will most likely let go in a matter of days. Hence: hot glue!

Step 6: The Container Itself

First I thought the lid was made out of acrylic, so I tried to drill a hole in it. Turns out it was made out of glass, and it broke. Clever! So, that's why I'm cutting out a sphere of acrylics with the same diameter as the lid, with a hole equal to the size of the PVC pipe in the middle. It turned out pretty cool, and I love the shine of new acrylic. Before putting on the frosted IKEA jar, we have to glue the stick of LEDs to the lid.

Step 7: Finishing Up!

We can see by the hole, and the placement of the electronic components, we can reach both the Arduino USB interface and the power input from underneath. I took a little shortcut on the legs, and used some potentiometer knobs I had lying around. Ideally you want some nice wood or maybe some turned aluminum?

Step 8: Done!

This was a great project, and I love it especially because it is so customizable and updatable in the future. I encourage you to look at the video in the top for the actual results. If you don't want the instructions, you can skip to the end to see the action.

Thanks for reading through, hope it was worth your time.

Hansi

<p>Hello,</p><p>This project was awesome! I've had my go at it and completed most of it. I didn't need a step down converter, I have a 5v power supply. However when I ran your code, I hit a snag, hopefully you can help me out.</p><p>I've wired everything together, led strip works in the setup function, however, it does not work with my current audio sensor. Only 3-4 leds blink... I presume this is because of the values I get from the analog read. I tuned it with the screw (potentiometer), got the sensor led to blink as expected. The serial out values are between 670 and 705, which goes up to 900 when I clap next to it. </p><p>Can you give me some info on this? It's my first arduino build btw, I've done some raspberries and tried my hand on Arduino.</p>
<p>Where can I get that power supply?</p>
<p>Did you ever sort your problem out? I have the same issue and the same module as yours...only the first 3 or 4 lights blink</p>
Yes I did. The problem is, the microphone has quite a poor sampling range. Here are some brief steps how I fix it: <br><br>1) Your microphone should have 2 leds on it. One for power the other one for noise. If both leds are on you need to twist the screw on the potentiometer (the blue thing) until one of the leds switches off. Now fine tune it (be in a quiet room and twist the screw while talking until it blinks with your voice) - This will be your sweet spot. In order to do this effectively, please continue reading :)<br><br>1a) To see the values coming in from your sensor (as you twist the screw), you need to modify Hansi's code a bit. I've already mentioned this in my previous comments, I'll paste a copy here:<br><br>-------------------------------------<br>To get the values out of your sensor all you need is an extra line of code. To the existing code, locate this part:<br><br>void visualize_music() {<br><br>int sensor_value, mapped, avg, longavg;<br><br>//Actual sensor value<br><br>sensor_value = analogRead(ANALOG_READ);<br><br>Add this line after the sensor_value:<br><br>Serial.println(sensor_value, DEC);<br><br>After you've done that, upload the code to the board. Once everything is ok, in your Arduino IDE, go to Tools menu -&gt; Serial Monitor / Serial Plotter. Serial monitor will open a window where you will be able to see the 10bit values from your sensor. Values will be in the range from (0 to 1023). Now depending on your sensor, you may have to adjust it using the potentiometer (yellow screw) using a small flathead screwdriver. Adjust until you get a decent result.<br><br>-------------------------------------<br><br>1b) For me the values that are decent are between 595 and 630 - this is quite a short interval so don't expect much blink of your lamp. Look at the values or plotted chard (if you use Serial Plotter). Turn on some music and talk around your sensor, you will see the changes. <br><br>2) Once you are happy with your values, you need to change the code further more. Please locate this variables in your code: <br><br>//The amount of LEDs in the setup<br>#define NUM_LEDS 150 --- make sure you have the correct number of leds here<br><br>//Confirmed microphone low value, and max value<br>#define MIC_LOW 0.0 --- change this to the lowest value you got from the serial out / plot chart - in my case I set to 595<br>#define MIC_HIGH 737.0 -- change this to the highest value you got from serial out / plot chart - in my case I set to 630<br><br>Now your lamp should behave decent :) I recommend getting a proper mic, like the one Hansi has. In any case, if you have any further questions, don't be a stranger.<br><br>Hope this helps. <br><br>Cheers,<br>Radu<br>
<p>Result can be view here:<br><br>https://goo.gl/photos/RUbk1qUiwDiniarB6</p>
Same problem with audio sensor
<p>Solution mentioned below. Read for user @mizark &gt; X-Pilot. This should help you</p>
<p>Cheap chinese sensors. I will try a preamp-ed version of the sensor, hopefully i'll have more values from serial. My current range is from 590 to 630. Lots of noise, not really reliable for music.</p>
<p>Found the one I used, might be better: https://goo.gl/14q2pB</p>
<p>Hello!</p><p>I committed a change to the code, so grab the new one. See the new macros that I defined? MIC_LOW and MIC_HIGH. Try to set low to the one you get from the analog read, when it is absolutely silent. High should be the highest value you can get out of it when you scream to it, or put on some really loud music right next to it - or something like that. Get back to me and tell me if that worked :)</p>
<p>How do I measure the analog read? A multimeter on the line? What pins do I measure between?</p>
<p>Hello Dragon 940C,</p><p>A multimeter won't work. Since the changes are very rapid, your multimeter will likely fail to get the correct values (since most multimeters have a delay in response to fast voltage changes).</p><p>For my initial development I used my DSO 203 pocket oscilloscope - this was purely done to check if the sensor was working without uploading the code. I recommend you get one (yes they are quite expensive, but in the long run you'll be able to debug a lot more electronics components and see binary data being sent as square waves. </p><p>Here's a link to my oscilloscope:</p><p><a href="http://www.ebay.com/itm/ARM-DSO203-Nano-V2-Quad-Pocket-Digital-Oscillo-scope-with-Aluminum-Black-Case-/200677575422?hash=item2eb950cafe:g:2qAAAOxyKsZRuBAP" rel="nofollow">http://www.ebay.com/itm/ARM-DSO203-Nano-V2-Quad-Po...</a> </p><p>I know it's expensive. Alternatively, you can build one yourself :)</p><p><a href="https://www.amazon.com/JYE-DSO-138-Open-Source/dp/B00WAQGGZA/ref=sr_1_2?ie=UTF8&qid=1489572304&sr=8-2&keywords=oscilloscope+kit" rel="nofollow">https://www.amazon.com/JYE-DSO-138-Open-Source/dp/...</a></p><p>Now, if you want just to get the values out of your sensor, you don't need all that. All you need is an extra line of code. To the existing code, locate this part:</p><p>void visualize_music() {</p><p> int sensor_value, mapped, avg, longavg;</p><p> //Actual sensor value</p><p> sensor_value = analogRead(ANALOG_READ);</p><p>Add this line after the sensor_value: </p><p> Serial.println(sensor_value, DEC);</p><p>After you've done that, upload the code to the board. Once everything is ok, in your Arduino IDE, go to Tools menu -&gt; Serial Monitor / Serial Plotter. Serial monitor will open a window where you will be able to see the 10bit values from your sensor. Values will be in the range from (0 to 1023). Now depending on your sensor, you may have to adjust it using the potentiometer (yellow screw) using a small flathead screwdriver. Adjust until you get a decent result. </p><p>Hope this helps :)<br><br></p>
<p>@X-Pilot -Thanks for the info it gave me what I needed<br></p><p><br>@Natural Nerd<br><br>-The new code is much better, much more control. </p><p><br> <br> <br> </p>
<p>Hello,</p><p>Thank you for uploading the code in such a short period of time. I appreciate it. I ran your code and I get better results. Not as cool as the one you got in your video but still, satisfactory for the first build. I believe this is because of the audio sensor. I couldn't find a part number or any data sheet on it :/ It was cheap, in any case, about 3$. I tuned it with the potentiometer to the sweet zone: values between 590 and 630. This seem to work best. The problem is I get little sample rate with this interval. Probably because of the sensor. I am thinking of upgrading to a preamp-ed sensor and see what results I get. </p><p>In other troubleshooting and electronic gnomes, I find that the lamp only works when the nano is connected to the USB... When I unplug the usb cable out of the Nano, the lamp freezes. Turning it on / off without a USB connection seems to break it. To describe this bug even further, it seems that Setup code runs ok, then the loop stops... I apologise for the newb question, but I don't know how to solve this. I've looked on google for an answer, but I couldn't find anything relevant. Hope you can help me with that as well.</p><p>Thank you.</p>
<p>You have powered the USB through VIN and GND with a 5 volt power source, when it is not connected to the USB? Else the Nano is off, and no code is running. Then the led strips usually just hold the state that it had when previously ran.<br><br>As for the sensor, that sucks! I couldnt find the one I used it my build, so I linked to another one, too bad it seems to be a really bad one. I had 0-737, not as much as what I hoped for, but it produces a decent result at least. </p>
<p>I have power on the VIN and GND pins on the Nano board. The wiring is common for the strip, audio sensor and Nano board. To be more specific:</p><p>Case 1: Nano board gets only external power</p><p>1) The system powers up as usual</p><p>2) The lamp turns blue in color (setup() function is called correctly)</p><p>3) Nothing else happens as if Nano does not enter loop() function</p><p>4) If at anytime I plug the USB from the Nano to a computer (I haven't tried an alternative power source) the lamp enters loop() function and works as normal</p><p>5) I pull out the USB connection from Nano. Leds freeze, nothing else happens. Led on the mic board still blinks as it still receives data from analog pin. All components are still powered by the external source.</p><p>---------------------------</p><p>Case 2: Nano board is connected to USB and external power. Led strip GND is disconnected not to overload the Nano board (since PWR and GND are all tied in parallel).</p><p>1) As soon as I plug in the led strip to ground, everything works as expected.</p><p>2) I pull out the USB connection from Nano. Leds freeze, nothing else happens. Led on the mic board still blinks as it still receives data from analog pin. All components are still powered by the external source.</p><p>3) Plug USB back into Nano. Lamp resumes normal operation. If I repeat step 2, same result.</p><p>I've attached some images. Of the build and pins. </p><p>Wiring: </p><p>Red - positive 5V</p><p>Black - GND</p><p>Green - Connects Nano (D6) to led strip</p><p>Blue - Connects microphone AOUT to Nano (A0)</p><p>Thank you for your help</p>
<p>That sounds really strange to me. Never had that kind of problem before. Please update if you figure out what's wrong</p>
<p>Hello,</p><p>I've figured out what is happening with the Nano - never buy cheap chinese hardware. So I dug around and I found that the Nano cannot work with just the pin external power supply. For some reason the loop() does not execute if there's no power supply on the usb bus line. To solve this, I will move the Nano power supply via a mini usb jack. I need just the positive 5V on the USB line, rest seems to work like a charm, even with the ground on the external pin.</p><p>I've added two video links below, describing the problem and solution :)<br><br>1st video - setup with only external power:</p><p><a href="https://goo.gl/photos/jHKDCg17kFWMiqhv6" rel="nofollow">https://goo.gl/photos/jHKDCg17kFWMiqhv6</a></p><p>2nd video - connect an external power source (in this case just your daily USB power transformer - only power no data) to the Nano. Note that the VIN pin is disconnected. Only common ground is present. </p><p><a href="https://goo.gl/photos/P3fysPKU1RrUCj9C9" rel="nofollow">https://goo.gl/photos/P3fysPKU1RrUCj9C9</a></p><p>Thank you for your support. This was an awesome build and a lovely thing to debug. </p>
<p>Also, since you are using a stepper down, I presume it includes a capacitor on the output (on the board). I am telling you this because, I've noticed . a voltage drop when the led strip is peaking, not too much, about 0.3 of a volt but enough to cause the resistor value to change on the mic sensor. I am planning to add a 100 uF capacitor, see if I can get more stable voltages.</p>
<p>Hi im a newbe at code, i keep getting errors,like CRGB does not name a type.thats just one of the many error,is there any chance you could send me the finished code plz</p>
<p>Anyone use an alternative jar? It wont let me order the Ikea jar suggested.</p>
<p>Hi!<br>How many meters LED did you use?</p>
<p>I'm really struggling with building this, the video is a little vague and some things aren't explained and it looks to be like quite a bit of things that are in the video weren't described in the supply list. Where do I start? In desperate need of help, any and all is appreciated!</p>
Hard work but after giving the led strip (150) an externsl power source all worked ...the nano powers only the sound sensor
<p>Hello. I have a question. Could I use a smartphone as a power supply?</p>
<p>Most likely no. <br><br>1) Led strips draw a lot of power - around 1.8A (120 led, full white). Your battery capacity (depending on your phone) is around 2.5A to 3A. So while the numbers look ok, it will drain your battery fast - not to mention that your phone will get very hot. <br><br>2) Now comes the second fun part. The USB on your phone needs to be USB OTG (on the go). To test this, plug in a usb memory stick. If it boots, you're good to go. <br><br>3) Current limiting by host - it's most likely a safety feature is added in these blasted devices, so if you exceed 1A power drawn it will cut the power to your strip.<br><br>Now if all conditions are met, it's theoretically possible. I managed to power my system with this little guy :) <br><br><a href="http://www.mi.com/en/pb10000/" rel="nofollow">http://www.mi.com/en/pb10000/</a><br><br>Benchmarked it, lasted around 4 hours until it went out </p>
<p>Cool lamp idea and thanks for sharing. I was also wondering if there was a way to use the sounds from my p.c. (inline) I almost aways have my headset on as not to disturb my wife. </p><p>P.S. Thanks for sharing.</p>
<p>Hey! What wires do you use? For the analog pins, can I replace them with just normal wires? Could I use normal wires for the whole project? Also, are there any more items I need to purchase besides the ones listed already? You used many different wires that you did not list.</p>
<p>Hello Hansi, </p><p>It seems like many people who tried this project got stuck at the same problem: the microphone sensor doesn't function as well as it should. I bought 4 of the same kind &quot;KY-038 Microphone sound sensor module&quot;, which is the same thing as the one you suggested. I tried with all 4 but came up with same results. No matter how I control the potentiometer, the sensor module produce analogue signal ranging between 560 and 572(when I set the potentiometer at the threshold, and used serial.println to see the analogue value on serial monitor) and the variance does not even exactly correspond with the volume of the sound around the microphone. I'm not saying something is wrong with your project, It is awesome project and I thank you for sharing your work. I just hope you can suggest us other cheap priced options for the good microphone modules. Maybe the one that you used in the video!</p><p>Thank you.</p><p>Jiesu</p>
<p>Ok, found the one I used! Project link updated: https://goo.gl/14q2pB</p>
Hello! Yes, I have seen that as well. It seems to be an issue with the microphone. I would have used the one I had, but I couldn't find it anywhere. I will take a second look to see if I can update it.
<p>Hello,</p><p>I have a 12v led strip...</p><p>Will it work?</p><p>Nice project and thanks</p>
<p>Hi! Congratulations for this project.</p><p>I'm trying to do it connecting directly the arduino to the power module. It's 5v, 1A. Should it work?</p><p>I can see that arduino is getting power but led strips aren't reacting.</p><p>Should I try with a power adapter with more Amperes?</p><p>If Anyone could help I would be very thankful.</p>
<p>With the way he programmed this you will need about 12ma (.012 amps) per LED. So 80 LEDs will need about 1 amp, 160 = 2 amps, etc. <br>This is the minimum power I would suggest using.</p><p>The reason this uses so little amps per LED is because the LEDs are never used to their full brightness.</p>
<p>thanks Dragon940C! i'll try this way!</p>
<p>How many of these LED strips that you linked would you recommend buying to make this?</p>
<p>It takes about 2 1/2 meters... so you can make 2 with a 5 meter strip.</p>
About 30 LEDs stay permantly on, it doesn't matter if I put my music louder or not, they always stay on. Does anyone know how to solve this? I did try to adjus the pot on the sound module, but this didn't do much. Thanks!
<p>I do have to add that I have a different LED strip, but the LEDs are adressable!</p>
<p><br> <a href="https://www.instructables.com/member/datasiphon" rel="nofollow">datasiphon</a> wrote a few days ago that the sound module has to be powered off before adjusting pot. I had to power off my module to get it to accept adjustment.</p>
<p>I actually did do that! And it did make a little difference but still 30-40 LEDs were constantly on</p>
<p>the same here ! maybe the range is to short....i use 90 leds .and adjusting the Sound module Switches the starting led ..Need help</p>
<p>My Atmel Studio project based on this source code here with some smaller changes. Improvements to come.<br><a href="https://github.com/engelchrisi/ReactiveLight/" rel="nofollow">https://github.com/engelchrisi/ReactiveLight/</a></p>
<p>I ordered the parts you recommended but the LEDs are delayed in shipping. I wanted to test with some Adafruit Neopixels that are WS2812B as well, only 60 LEDs though. I seem to be getting a lot of LED action when it is almost quiet. I'm using 2 different Uno clones and both have that issue. any ideas?</p>
<p>Adjust the pot on the sound module.</p>
<p>Thanks for the quick response! Adjusting the POT did get this working but it seems you can't adjust the POT while it was powered on.</p>
Have you tried giving it some sound for a while? It works on averages, meaning that if quiet is the average, any sound will make it act. This is because to me working on hardcoded values of the sensor, made it very difficult to predict typical strong sections of a song.
<p>The America IKEA doesn't have the tall Dropper Jar, is there a different jar I should use or should I just do a size down.</p>
That all depends on how big you want your lamp! You could reduce the size, and also reduce the amount of strips. Or go for a different jar entirely.
<p>Thank you for previous answer.</p><p>In order to reduce the cost to make this project,</p><p>I wish to use a only 1 color LED strip.</p><p>I have three questions for you.</p><p>1. Would this work if I connect 1 color LED strip instead?</p><p>2. Where in your program, should I fix in order to use 1 color, instead of 3 color LED strip?</p><p>3. Is your program only applicable to WS2812B, or can I use other kinds of Individually Addressable LED-strip as well? If so, what are the names of them which are applicable with this project?</p><p>Thank you for your help :)</p>

About This Instructable

34,785views

646favorites

License:

Bio: We are a couple that loves creative projects, and retro gaming. We will be posting anything that we make related to it, with DIY videos ... More »
More by Natural Nerd:Shadow Box: Gandalf Fighting the Balrog! Glossy Custom Gamecube Controller Mod Companion Cube Storage Box 
Add instructable to: