Introduction: Arduino Powered Musical Christmas Lights

After exploring the Instructables website I found a few projects that peaked my interest and those lead me to thinking, I could make some musical Christmas lights. Most of what I spent my time on came from Amanda Ghassaei's Instructable on Frequency Detection. I owe a lot to her work! The rest is simple use of relays.

I also want to preface this Instructable with the fact that I did not make this one to look pretty behind the scenes and some of the pictures will not match my instructions because after doing the project myself there are a few things that I would do differently, which I include in the Instructable. Also, I am by no means a professional! This is a recent hobby and I am sure that many improvements could be made, so feel free to make improvements but please leave comments so that people can use them in the future as well.

Items you will need:
Mp3 player (any will work)
Stereo with audio in (or transmitter if you already have the know how to broadcast like the cool houses)
3.5 mm audio cable (from old head phones or wherever)
3.5 mm audio splitter (one lead to the Arduino the other to the stereo)
Arduino Uno
2.1mm power plug (for the Arduino)
Extension Cord (that you can cut up and use)
2 10k resistors (brown, black, orange)
1 10 µf capacitor (polarized)
5 150 ohm resistors (brown, green, brown)
1 pack of jumpers and headers  (
5 Solid State Relays  (digikey part number 425-2395-5-ND)
Protoboard (preferably one with the copper rings)
Solder-less board (optional but encouraged)
5 electrical Sockets from local hardware store
Electrical boxes for the sockets
4 Zip ties and a drill

Step 1: Setup Audio Input

The first thing that you will want to do is setup the audio input and test it to make sure that you are reading frequencies. To do this you will want to set it up the components like in the schematic shown on this page. I recommend doing it on a breadboard first so you can test it before soldering and committing to the setup.
Attached to this step is a compressed file with an Arduino Sketch you can load directly to your Arduino. Once you load the program and start playing a song you can look at the frequencies using Arduino's serial monitor or make a txt file using the program I built, which is also in the file.
Once you are sure that the configuration is working for you, solder a pair of the jumpers from the jumper kit to the bottom of a protoboard to plug into your Arduino and solder your other components together on the top with the resistors soldered to the jumpers.

Your Arduino will power itself through the USB cable, but if you are like me you don't want your computer attached to this all of the time. So this is where your power connector comes into play. The Arduino uses a center positive configuration and can use 7-12 volts ideally (see for details). Find what wire goes to the center and hook that to the positive of your power source and the outside sleeve to the GND or negative. You can use a 9V battery or any other power supply that meets the Arduino's requirements. I personally tried a 9V battery and changed to one of the 12V leads from the PC power supply that I use to power my car stereo deck converted to home stereo that I use with this project. Just a warning, if your battery voltage drops below about 7V the 5V output drops to about 2.49 and your display stops working. I had this happen once, right after making a few changes to my setup, and it took a few minutes to figure out for sure that the battery was too low and causing the problem.

Step 2: Test the Digital Outputs

Now you will want to speed up your program. To do this comment out the lines:

Serial.println(" hz");

Once you have commented out these lines and uploaded it into the Arduino you can test your output one of two different ways. You can either skip this step and just hook up your relays and test with the relays, or you can use LEDs. I personally tested it with LEDs first because they have the same power requirements, depending on your LED, as the solid state relay. 

To test with LEDs just use a jumper to bring the ground from the Arduino to the ground rail on the breadboard. Plug each LED's cathode into the ground rail and then use the 150 ohm resistors to connect pins 8-12 to the anodes of the LEDs. Enjoy the light show!

Step 3: Wiring the Outlets

After testing to make sure this all works you will want to assemble the outlets and test the relays themselves.  I apologize for not having more pictures but I made the lights and then decided to do the Instructable and I don't want to take it apart just for pictures. So please make sure that you read all the way through first, then do. 

The first thing that you will want to do is connect your electrical boxes that you got for outlets. To do this you will be making two pairs of holes, one set towards the top of the outlets and the other towards the bottom, about halfway from back to front. These wholes will be for the zip ties to go through. Start by grabbing a box, I recommend a bigger one first, and drill the first pair of holes about an inch apart and then drill the second set about the same. You will have to do this again in the other boxes to link them together so I recommend using a marker, or something you can see on the boxes, to mark through the holes you just made and onto another box. This is why I recommend starting with a larger box. Once you have drilled the holes, lace the zip ties through and tighten them to link the boxes. If you like you can use other creative methods. 

After you have the boxes together then start wiring. Here is where you will want your extension cord. I used a stiffer wire, generally used in walls, and it was much more difficult to work with and made soldering problematic. Inside your cord there should be three wires black, white, and green.The black is the "neutral" wire, white the "hot" wire, and the green is the true ground wire which is connected to that bottom third prong. Connect the neutral wire (black) and the ground directly to your outlet. if you don't know how to do this ask someone at the hardware store or a friend who knows more, otherwise just don't do this project because this is high voltage and can hurt you or others. Since the neutral and ground are directly connected you can link all the plugs together with the neutral and the ground. It is the hot wire that we will be using with the relays. DO NOT string the hot wire (white) together between outlets or your lights will always stay on. Use the hot wire from the cord, left over from connecting the outlets neutral and ground together, to make a separate lead for each outlet which will connect to the relays.

Now the relays. On each relay there is 4 pins two marked "~", one "+" and one "-". Place each relay on the protoboard with 3 rows between them so that they won't touch each other when soldered together. Solder all of the "-" together with a wire, or jumper, for easy connection to the Arduino's GND on the digital side. Now solder each of the 150 ohm resistors to their respective relays. Use a row of 5 jumpers to easily and cleanly connect the jumper wires to the Arduino, then connect the other end of the jumper wires to the resistors that you just soldered to the relays "+" terminals.

Now solder all of the inside "~" terminals together and solder the hot wire from your extension cord to the row as well. Now Solder the individual wires from your outlets that you connected earlier to their respective relays outside "~" terminals.

Once you have soldered all of these together make sure that your outlets are covered and plug in a string of lights to each outlet set and test your configuration just like in step 2.

Step 4: Enjoy!

Now that you have everything hooked up and ready to go, feel free to tinker with the code but make sure to put comments on the page if you find anything better so that others can enjoy the improvements as well.

I will try and do my best to answer any questions and others feel free to answer questions if you know the answer. 

Youtube video:


mattrawson02 made it!(author)2017-03-05

there are three wires in the audio cable ground,right,left which one do i use for reading hz on the arduino

MSargent99 made it!(author)2016-12-19

Ported the code to work on an Arduino Micro.

Also have a board set up using small N-channel MOSFETS to control six strings of LED lights that run off 3xAA batteries. So suitable for setting up on a small tree or other small Christmas decoration.

Again thanks for a great project!


timmurphy4 made it!(author)2015-12-02

Amazon has this 8 channel SSR:

The load current is only 0.1 to 2 AMP. A 100 light string of mini-lights = 1/3amp or .33amps. Should work. Extension cords could be an issue. Look at this site then choose:

I bought this. I'll tell you how it goes when it comes in.

timmurphy4 made it!(author)2016-02-10

It worked, the wiring took a while. I made an out of focus video, but, it's still fun.

TylerV3 made it!(author)2016-01-31

Nice project, made it, but I can't figure out how to put the pictures. Just curious if anybody had the problem of the lights not lining up with the music sometimes?

redsox38 made it!(author)2015-12-07

Thanks for sharing! I'm going to try this out with my mega and an 8 relay module that I have. I'm thinking that I'll wire a 1/4" audio input to the protoboard rather than cutting up a cable. Would I just drop that in front of the capacitor?

DavidR231 made it!(author)2015-12-10

I did it with a mega. The big change from the uno code is the pin numbers for the port manipulation. Once I figured that out it was all smooth sailing.

redsox38 made it!(author)2015-12-13

I got the port mapping worked out with some work, the Arduino documentation for the port mapping is not correct for the mega 2560, but I found which has correct mapping and it looks like I'll have to use some of the high pins to find 8 contiguous pins in the same port. Should be smooth sailing the rest of the way.

MSargent99 made it!(author)2015-12-08

Great project!

Got my prototype up and running in just a couple hours using leds directly off the pins. I also put a small stereo-mono adapter (?) in front of the capacitor. And for my first iteration I am just using a USB power supply and it works fine.

For my next iteration I want to use an 8-channel relay module and figure out the code modifications to get that working with a couple real strings of lights. I'm sure someone has already modified the code for that. Can anyone point me to a link?

What would be great is to figure out a way to drive a small speaker or buzzer type thing to be able to hear the music being played and 'flashed'. Anyone try something like that?

Thanks again for this great project!


DanS82 made it!(author)2015-12-06

Is it possible to read from A0 and A1 simultaneously using the method in your code? I'm just not that familiar with the method you're using. Basically I'd like to set this up with stereo audio.... left audio (a0) controls 'left lights' and right audio(a1) controls 'right lights' Thanks! If I cannot use your method, is using analogRead() going to give me too much lag on the outputs? I'm already using solid state relays.


thone made it!(author)2015-12-06

So I borrowed the audio input from another Instructable. The method used in mine does not allow you to use both A0 and A1 at the same time. Also, analogRead() ends up being slower. You could try it but I can't guarantee the results. Here are the links for the other Instructables.

DanS82 made it!(author)2015-12-06

Thanks for the reply, I was afraid I wouldn't be able to use Adch to read both simultaneously but that's alright. I currently have an Uno (16MHz clock) but if analogRead() is noticeably laggy with the light outputs, my housemate has offered up his RaspberryPi (900MHz clock) to try. I think the analogRead() command is only ~10 or 15 executions so with a 16MHz clock it should take 625ns-940ns (or 11ns-17ns with a RaspberryPi). If I use the command twice it should only add ~2ms per loop max with an Uno. If I can notice that.... I'll be surprised :) I'll post code and results when I have a finished product in a couple of weeks here :)

DanS82 made it!(author)2015-12-06

Just found this helpful tidbit on the arduino website "It takes about 100 microseconds (0.0001 s) to read an analog input" so using it twice I add about .0002s of delay. Seems like that shouldn't make a difference. Will update.

LukeH31 made it!(author)2015-11-15

Can anyone tell me a better place to get the relay because I don't want to spend $2000+ for 500 of them when I only need 7 at most any ideas are greatly appreciated.

Also is the lights to be powered by the ardunio if so how? I have my roof covered in incandescent lights but the front in LED there is absolutely no way a 9 volt or even 12 volt could power that so am I misunderstanding something if so can someone enlighten me. Again any information is greatly appreciated.

thone made it!(author)2015-12-01


I am sorry that I haven't replied to this comment before. I am not online very often due to work. DavidR231 basically summed it up. To further clarify, the relay should have four prongs. Two are for the AC current and need to be rated for 120 volts and enough amps to support your lights. The other two are for your 5 volts DC that are coming off of the Arduino. The AC prongs basically go in the middle of one of the AC lines going to the outlet for the Christmas lights. One of the DC prongs will go to the ground on the Arduino and the other will go to pin 8, 9, 10, 11 or 12. There is one relay per pin and each pin is for a different zone.

I hope this helps. I am probably too late for your light competition.

DavidR231 made it!(author)2015-11-20 has the relays at a reasonable price and you can order in small quantities. I ordered 10 to take advantage of the price breaks, but you could probably only get one if you wanted to.

The lights are powered from a wall outlet. The Arduino just switches the relays which determine which of the project's outlets has power at a given time. The author uses a cut-up extension cord to wire the outlets, I am using regular 12/2 electrical wire.

If you are at all unsure about wiring outlets, you should definitely look for some help.

DeanP2 made it!(author)2015-11-24

I have this mounted in my garage and ready to go. I am feeding it with the output of a radio that I leave on, but everything is controlled by a timer. In the evening the timer kicks on, the radio powers up, the arduino boots, and power is sent out to the lights.

I have tinkered with the code a bit, and I do have one channel that seems to get stuck. I'm not sure if a specific relay is getting sticky, or I have altered the code in a way that leaves on relay on for an extended of time. Since I'm only running lights off of three of the four channels, I just plugged the stuck lights onto the unused channel and I still have a show where all lights flash.

One channel runs two Christmas trees created by covering inverted tomato cages with garland and lights.

Thanks for a great project.

thone made it!(author)2015-11-26

Thanks for the complement. I went through and did this just for fun as I was getting into electronics as a hobby and just thought I would share what I had since so many other Instructables helped me to build this setup.

thone made it!(author)2015-11-26

Thanks for the complement. I went through and did this just for fun as I was getting into electronics as a hobby and just thought I would share what I had since so many other Instructables helped me to build this setup.

AlannaR1 made it!(author)2015-11-19

I'm just wondering if you can simplify this for little christmas lights for a little christmas tree?

thone made it!(author)2015-11-26

I imagine that you could do something like this for a Christmas tree, but you still have to have separate zones. The easiest way to do that would still be to have a strand of lights for each zone. I honestly Frankensteined this project together from other projects I found and then tweaked them to work for me. I would recommend the same for you.

imaloney made it!(author)2014-11-30

Hi I'm going to try this in my dorm room with maybe 8 different channels. I've got some Arduino experience so I shouldn't have any problems there. Any other advice for me?

thone made it!(author)2014-12-02

Nothing new really. If you have some experience with Arduino then I bet that you have some experience with electricity in general. I just want to take the opportunity to say again to everyone, please be careful and don't shock yourself while building it (i.e. don't work on it while it's plugged in). In a dorm room make sure that you take extra care to cover all of the 120v wires properly so you don't short anything and start a fire.

vkp65 made it!(author)2014-11-27

Great instructions, tested it using the LED works perfect, next step going to add the relays, I was wondering if there is way to increase the number of channels?

thone made it!(author)2014-11-27

Yes. All you would have to do is use the remaining pins (2-7), include them in the code and play with the frequencies for each of them until you are happy with the results. If you buy one of the bigger arduino boards it has even more outputs.

BirryA made it!(author)2014-10-31

how much voltage you use to load? I've read the datasheet of relay you use, it's 120VAC. can i use it for voltage load 220VAC?

thone made it!(author)2014-11-07

Only if you had 220VAC lights. Basically all I was doing is using solid state relays as a controllable light switch by putting them in series with the supply to the sockets.

achandler6 made it!(author)2013-12-20

I saw online that the black wire is supposed to be the "hot" wire and the white is neutral... should I still follow your given directions? Thanks, great project!

thone made it!(author)2013-12-20

You can wire it either way as long as you are consistent and make sure you switch the hot wire and not the neutral.

Kdaver21 made it!(author)2013-11-29

This is awesome! Did you used a mono signal for the audio cable?

thone made it!(author)2013-12-18

I actually just used a regular stereo audio cable.

Kjf77 made it!(author)2013-12-17

I used a mono cable from the splitter to the Arduino and I get a bunch of random gibberish frequency vales. Need to retry with a stereo plug.

amandaghassaei made it!(author)2012-12-18

looks awesome! definitely post that video and send me a link when it's up

thone made it!(author)2012-12-21

Video is up

amandaghassaei made it!(author)2012-12-21

love it! just a suggestion- take a frame from the video and set it as your main image, also embed the video in the intro, that way people will have I better idea about what the project is when they see it browsing through the related or recent feeds.

Lectric+Wizard made it!(author)2012-12-19

Awesome project ! Would like to take a look at your code but when I try to open or download, all I get is an htlm of giberish. Can you include it in text format or something similar.Thanks!

thone made it!(author)2012-12-21

I posted a ZIP file. Let me know if that helps. I don't know how to do a scrolling window in the Instructable and the code takes up a lot of room.

thone made it!(author)2012-12-21

The video is up

thone made it!(author)2012-12-19

I had attached an RAR file and I know some people might not use it much so I attached a ZIP file as well. Hope this helps. I don't know how to put a scrolling text window in my instructable and it takes a lot of space or else I would just put the code straight on the page.

About This Instructable




More by thone:Arduino Powered Musical Christmas Lights
Add instructable to: