Introduction: Music Reactive Desk Lamp

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

Picture of 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

Picture of 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

Picture of 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

Picture of 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?

Picture of 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

Picture of 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!

Picture of 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!

Picture of 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.



eyjayrel (author)2017-11-25

can I use the 5V 1.5A smart phone charger to power all three components ( arduino, module and strip )? please reply

X-Pilot made it! (author)2017-03-11


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.

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.

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.

Natural Nerd (author)X-Pilot2017-03-11


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

eyjayrel (author)Natural Nerd2017-11-19

hello sir, can I see the new code that you've made?

Dragon940C (author)Natural Nerd2017-03-14

How do I measure the analog read? A multimeter on the line? What pins do I measure between?

X-Pilot (author)Dragon940C2017-03-15

Hello Dragon 940C,

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).

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.

Here's a link to my oscilloscope:

I know it's expensive. Alternatively, you can build one yourself :)

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:

void visualize_music() {

int sensor_value, mapped, avg, longavg;

//Actual sensor value

sensor_value = analogRead(ANALOG_READ);

Add this line after the sensor_value:

Serial.println(sensor_value, DEC);

After you've done that, upload the code to the board. Once everything is ok, in your Arduino IDE, go to Tools menu -> 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.

Hope this helps :)

Dragon940C (author)X-Pilot2017-03-15

@X-Pilot -Thanks for the info it gave me what I needed

@Natural Nerd

-The new code is much better, much more control.

X-Pilot (author)Natural Nerd2017-03-12


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.

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.

Thank you.

Natural Nerd (author)X-Pilot2017-03-12

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.

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.

X-Pilot made it! (author)Natural Nerd2017-03-13

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:

Case 1: Nano board gets only external power

1) The system powers up as usual

2) The lamp turns blue in color (setup() function is called correctly)

3) Nothing else happens as if Nano does not enter loop() function

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

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.


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).

1) As soon as I plug in the led strip to ground, everything works as expected.

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.

3) Plug USB back into Nano. Lamp resumes normal operation. If I repeat step 2, same result.

I've attached some images. Of the build and pins.


Red - positive 5V

Black - GND

Green - Connects Nano (D6) to led strip

Blue - Connects microphone AOUT to Nano (A0)

Thank you for your help

Natural Nerd (author)X-Pilot2017-03-13

That sounds really strange to me. Never had that kind of problem before. Please update if you figure out what's wrong

X-Pilot (author)Natural Nerd2017-03-14


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.

I've added two video links below, describing the problem and solution :)

1st video - setup with only external power:

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.

Thank you for your support. This was an awesome build and a lovely thing to debug.

X-Pilot (author)Natural Nerd2017-03-12

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.

mizark (author)X-Pilot2017-03-23

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

X-Pilot (author)mizark2017-03-31

Yes I did. The problem is, the microphone has quite a poor sampling range. Here are some brief steps how I fix it:

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

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:

To get the values out of your sensor all you need is an extra line of code. To the existing code, locate this part:

void visualize_music() {

int sensor_value, mapped, avg, longavg;

//Actual sensor value

sensor_value = analogRead(ANALOG_READ);

Add this line after the sensor_value:

Serial.println(sensor_value, DEC);

After you've done that, upload the code to the board. Once everything is ok, in your Arduino IDE, go to Tools menu -> 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.


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.

2) Once you are happy with your values, you need to change the code further more. Please locate this variables in your code:

//The amount of LEDs in the setup
#define NUM_LEDS 150 --- make sure you have the correct number of leds here

//Confirmed microphone low value, and max value
#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
#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

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.

Hope this helps.


kamifernando (author)X-Pilot2017-10-05

Thanks man. It worked pretty fine..!!!!! But theres a small problem where my led strip doesnt change colours... it works in an off-white colour. I'm guessing some numbers in the code need to be changed.. my high and low values were 504 & 536. It would be better if it changed colour

X-Pilot (author)kamifernando2017-10-07

Check the audio-high and audio-low values where colors are changing. Unfortunately I did this quite a long time ago and I can't remember exactly what was happening. In any case, you can check the fastled library to set your own color ramp mode. If you want, you can use fast led initially to test your led strip (no music reaction) and once you got a nice looking result, you can add that function in this project. Sorry for the shallow response - I gave the lamp to a dj friend who simply loves it... so I can't really try it out anymore :(

X-Pilot (author)X-Pilot2017-03-31

Result can be view here:

MarcelR23 (author)X-Pilot2017-03-11

Same problem with audio sensor

X-Pilot (author)MarcelR232017-03-31

Solution mentioned below. Read for user @mizark > X-Pilot. This should help you

X-Pilot (author)MarcelR232017-03-12

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.

Natural Nerd (author)X-Pilot2017-03-16

Found the one I used, might be better:

Delta1Dan (author)2017-11-14

Hey, I wanted to use this project but instead of having the audio sensor, could I just connect it straight to an audio source using a jack cable? Or would that require extra code?

Alan-brito (author)2017-05-10

Hello, I have a question. I would like to do this but I dont have the "Individually Addressable LED strips"

Can I do that whit an RGB Led Strip?

EdwardF2005 (author)Alan-brito2017-07-17

RGB strips with R G B and GND input wouldn't work. In the tech world these are called 'dumb' led strips. the WS281B LEDS that they were using are induvidually addressable and called smart LEDs

xilense (author)Alan-brito2017-05-10

hi alan, i think it would not work with RGB Led Strip

nacbooth made it! (author)2017-06-02

Great fun to make. I used a different casing, but loved the idea of a spiral wound core for the LED strip which I've put into this this Chinese lamp box which has a great diffused screen. Thanks for the code and ideas.

Natural Nerd (author)nacbooth2017-06-02

That is fantastic!

AaronM255 (author)2017-05-18

Hello I have done what they said for the blinking, the problem is that it does not change my color, you are only in blue. What can I do?
Thank you and sorry for my bad english

igordon18 (author)2017-05-03

Hey! A friend and I are building this together and everything seems to be working pretty well, however, the LEDs are not changing color. We have made a few edits to the code in the MIC_LOW and MIC_HIGH areas as suggested in the comments and have adjusted the low and max values, and nothing has worked. Any ideas?

JONATHANW177 (author)2017-05-01

I keep on getting the error of error: 'leds' was not declared in this scope

is there any way to fix it, I tired a couple of things but nothing is working

marks789 (author)2017-04-12

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

17berhey (author)2017-04-10

Anyone use an alternative jar? It wont let me order the Ikea jar suggested.

RobertB26 (author)2017-04-09

How many meters LED did you use?

igordon18 (author)2017-04-03

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!

MarcelR23 made it! (author)2017-03-31

Hard work but after giving the led strip (150) an externsl power source all worked ...the nano powers only the sound sensor

gabriele99 (author)2017-03-22

Hello. I have a question. Could I use a smartphone as a power supply?

X-Pilot (author)gabriele992017-03-31

Most likely no.

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.

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.

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.

Now if all conditions are met, it's theoretically possible. I managed to power my system with this little guy :)

Benchmarked it, lasted around 4 hours until it went out

RaymondL56 (author)2017-03-31

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.S. Thanks for sharing.

bbland18 (author)2017-03-28

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.

Dragon940C (author)2017-03-16

That's the sound module I used and it worked fine. The potentiameter didn't effect sound too well but I played with his code and changed the two lines to this:

//Confirmed microphone low value, and max value
#define MIC_LOW 200.0
#define MIC_HIGH 700.0

Once I did that I got pretty good results.

Jie SuY (author)2017-03-15

Hello Hansi,

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 "KY-038 Microphone sound sensor module", 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!

Thank you.


Natural Nerd (author)Jie SuY2017-03-16

Ok, found the one I used! Project link updated:

Natural Nerd (author)Jie SuY2017-03-16

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.

IlirD2 (author)2017-03-14


I have a 12v led strip...

Will it work?

Nice project and thanks

illera (author)2017-03-07

Hi! Congratulations for this project.

I'm trying to do it connecting directly the arduino to the power module. It's 5v, 1A. Should it work?

I can see that arduino is getting power but led strips aren't reacting.

Should I try with a power adapter with more Amperes?

If Anyone could help I would be very thankful.

Dragon940C (author)illera2017-03-07

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.
This is the minimum power I would suggest using.

The reason this uses so little amps per LED is because the LEDs are never used to their full brightness.

illera (author)Dragon940C2017-03-08

thanks Dragon940C! i'll try this way!

igordon18 (author)2017-03-02

How many of these LED strips that you linked would you recommend buying to make this?

Dragon940C (author)igordon182017-03-06

It takes about 2 1/2 meters... so you can make 2 with a 5 meter strip.

About This Instructable




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:Electric Wooden Drink DispenserMini Fridge for a Camper Van or Desktop!Iron Throne Phone Charger
Add instructable to: