Introduction: Christmas Lights to Music Using Arduino

My wife and I have wanted to create our own lights-set-to-music show for the last few holiday seasons.  Inspired by the two Instructables below, we decided to finally get started this year and decorate our RV.  We wanted an all-in-one controller (lights AND music) but didn't need it to be controllable over the internet, making it a little different than the other two Instructables.


Video to come!


Sources I've Used:

Instructables:
Arduino Christmas Light Controller
xmas-box: Arduino/ioBridge internet controlled Christas lights and music show

Other:
Solid State Relays (SSRs) Using TRIACs:


Step 1: Parts You'll Need

SSR Supplies ($7):
MOC3031 Optocoupler (8)
Z0103 TRIAC
(8)

Light Controller Supplies ($61):
Arduino Duemilanove
WaveShield

FM Transmitter - I made one (shown in the photos below) but any will work ($15+)

RadioShack B&M ($14):
Wire Terminals (3 packages, 12 connectors) 276-1388
Printed Circuit Board 276-147 (could use smaller)
330ohm Resistors (2x 5-packs)
150ohm Resistors (2x 5-packs)

Home Depot B&M ($25):
50 ft Landscape/Sprinkler Wire (18ga, 7 conductor) 079407238170
6' Power Cords (x8 minimum, to use the female 120v connectors)
-you may need more than 8, depending on the locations of your lights; I used 11
Clear Plastic Box (my Dollar Tree was out but HD had these for $0.87)

Miscellaneous:
Soldering Iron (I use a butane-powered BernzOmatic from Home Depot; doubles as a heat gun)
Solder (highly recommended: Soldering Paste)
Screwdrivers (philips for WaveShield, standard for wire terminals)
Wire (for WaveShield and connecting to the SSRs, I used extra breadboard jumper wires I had)
Diagonal Cutters
Wire Strippers
SD Card (any size, I used 64MB)
Electrical Tape
Power source for Arduino (I used an extra powered USB hub I had)
Hot glue gun
Wire nuts (optional)

Step 2: SSR Board

Solid State Relay Board

If you like, you can also view full-size copies of my schematic and board.

I started by placing all the components on the board.  When I was satisfied with how they were laid out, I started by soldering all the items to the board that didn't need extra wire (basically, everything but the ground from the Arduino and the 120v hot line).  I then soldered the common grounds/hot wires.  As you can see from the bottom of the board, it looks rather messy.

When finished, I tested each SSR separately by hooking up the 120v power and measuring across the neutral and each switched hot output while I put a 5v source across the Arduino side of the board.

Step 3: Add the Arduino

I used a hot glue gun to secure the Arduino board to the SSR PCB.

If you decide to solder an FM transmitter directly to the PCB, you can add it in the extra space in the bottom left of the photo below.  Otherwise, you can also plug in any generic FM transmitter.

Step 4: Construct the WaveShield

Follow the excellent directions at Lady Ada to construct the WaveShield kit.  I used the default control pins (2 - LCS, 3 - CLK, 4 - DI, 5 - LAT, 10 - LCS).  I also connected pin A0 to the 1.5k resistor at R7 (see photo below).

When finished, follow the directions here to prepare songs and transfer them to your SD card.  Place the card in the WaveShield when finished.

Step 5: Connect to the SSRs

I used the extra breadboard jumper wires I had to connect the following:

WaveShield (these can be changed but I used the defaults)
D2 - LCS
D3 - CLK
D4 - DI
D5 - LAT

First 3 SSR Channels
D6 - Channel 1
D7 - Channel 2
D8 - Channel 3

WaveShield

D10 -> LCS

WaveShield - SD Card (cannot be changed)
D11
D12
D13

Power
Gnd[0] - SSR Ground

Vu Meter
A0 - Connect to R7 (1.5K resistor) on the WaveShield to measure output from amplifier.

Remaining 5 SSR Channels

A1 = D15 - Channel 4
A2 = D16 - Channel 5
A3 = D17 - Channel 6
A4 = D18 - Channel 7
A5 = D19 - Channel 8

Step 6: Upload Sketch and Test Everything

I used a short length of the landscape wire to test the setup.  I connected the black wire to the neutral wire terminal, and each of the other six conductors to the first six SSR hot wire terminals.  On the other end of the landscape wire, I connected all the neutrals to the black conductor and each of the other six conductors to the hot wire of each of six female electrical outlets (see photo below).  To supply power, I connected one of the six foot male power cords left over from harvesting the female connectors into the 120v input wire terminals (see photo below)

I used xmas_box.pde from here and set debug to true while testing everything.  I plan on editing the code once I get everything set up outside but for now it works without modification.

Update 2010-06-22: I've attached a 7-zip file containing code I might have used (besides the original code from above).  I'll upload new code later this year when I put the controller back together and implement some of the ideas I had for future expansion.

Update 2010-12-11: I've re-written the program using the daphc example from the WaveHC library and the VuMeter code from the xmas_box Instructable linked above.  It will now play any song it finds on the WaveShield's SD card in a continuous loop.  The program is Christmas_Lights_2010.pde below.  I've also included Christmas_Lights_2010_Channel_Test.pde which just cycles through all 8 channels so you know that they work.

Step 7: Put It All in a Box

I started by hot gluing the circuit board into the clear plastic tub.

I had an extra powered USB hub laying around so I decided to use that to power the Arduino.  I hot glued the power adapter for the hub into place and plugged the 11th 6' extension cord (the only one not cut up) into it.  I also glued the hub in place.  Into the opposite side of the extension cord, I plugged in the circuit board's 120v plug.  The USB cord going to the Arduino from the hub is a $1 extend-able cord from Dollar Tree but any USB cord would work.

To run the cords through the side of the tub, I used my soldering iron with the tip removed (effectively a mini heat gun) to melt away the plastic.  I then used hot glue to secure the cords in place.  I did this with the lights' power cords (top of the picture below) and the power cord for the board (bottom).

I finished it up by using wire nuts to connect the power going out to all the lights to the test wires I had already hooked up (adding an additional two for the 7th and 8th channels).  Add the lid and you're all set.  Should be waterproof-enough for me and it's protected by the front steps of my RV.

Step 8: Hook Up Christmas Lights

Run the landscape cables to all of the lights and wire the female 120v connectors.  Each connector is connected to both the black wire and one of the six colors (one for each channel in the cable).  I ended up running two lengths of cable (to cover all 8 channels).

You may need more than one female 120v connector per channel.  I used two per channel for both my miniature trees and my reindeer (there is one on each side of a central Christmas tree).

Step 9: Ideas for Changes

Expansion:

There are 3 extra pins on the Arduino available to add extra channels.  I'll probably add these three next year (or go with both of the next two options).

Use higher-powered TRIACs, such as the 4A Z0405
     -as long as you are using LED lights, 1A should be PLENTY

Use a shift register so that you can have more than 11 channels.

Comments

author
kldewitt87 made it!(author)2017-04-20

This is going to sound really stupid but can you give me a run through of how you connected the Christmas lights to the Arduino so that they work with the music? I can't remember how I set it up last time I ran it. Thanks!

author
kldewitt87 made it!(author)2017-04-20

Never mind. I figured it out.

author
MRedmon made it!(author)2017-01-21

The 2010 update included a change to the WaveHC library. It's on the bottom of Step 6.

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

Can you use the Arduino Uno instead of the Duemilanove?

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

Yes.

author
kldewitt87 made it!(author)2015-12-24

I have finished everything and done all of the wiring. However, only 3 of my SSR channels work. Is there something I am missing? Will attach pictures if necessary.

author
MRedmon made it!(author)2016-11-30

I don't know. Did you ever get it work?

author
kldewitt87 made it!(author)2016-12-01

I have almost got it. I have to adjust one small part of the code because the lights only blink in tune for some songs and not others. This is a great project though :)

author
kldewitt87 made it!(author)2015-12-24

Do I need the xmas_box.pde?

author
MRedmon made it!(author)2016-11-30

No

author
ChristianL143 made it!(author)2016-11-21

are these all 1/4 watt resistors? Just making sure.

author
MRedmon made it!(author)2016-11-30

As best as I can recall.

author
kldewitt87 made it!(author)2014-12-18

Can you recommend any particular FM transmitter? I know you made yours. I just haven't quite found what I'm looking for in that way of one.

Thanks so much for your help!

author
MRedmon made it!(author)2014-12-24

No, any should work.

author
kldewitt87 made it!(author)2014-12-24

I finally managed to find the one I wanted. Thanks! :)

author
kldewitt87 made it!(author)2014-11-09

The link for the optocoupler no longer shows anything on the website. Which one do you recommend as a substitute? Also, are the numbers in parentheses supposed to be how much of each you thing you need?

Thank you!

author
MRedmon made it!(author)2014-11-09

I'll update the link. You can always search for the part number... they still carry the exact one I used:

http://www.mouser.com/ProductDetail/Fairchild-Semi...

Yes, the numbers in parentheses is the number needed (though read through the Instructable because you might want more).

author
rdgrahamjr made it!(author)2013-12-21

This is pretty cool light controller. I am sharing this on my blog rdgraham.com for my share a post Sunday.

author
Techperson_1 made it!(author)2013-12-06

Hi, I'm a newbie and I bet this must be obvious but which MOC3031 do I choose?

I have pictures below of the options.

Screen Shot 2013-12-06 at 10.31.24 PM.jpgScreen Shot 2013-12-06 at 10.31.47 PM.jpg
author
dreos made it!(author)2013-11-26

Just wanted to say thank you and thank Lady Ada. Followed the directions with a few exceptions (bought the SSR's built) and this works perfectly. My kids are going to go nuts. Many thanks. I can't wait until the next project. The Barron Fourier and Kings of Leon

author
SadPanda284 made it!(author)2012-10-25

I am somewhat new to this hobby, & wanted to started with a slightly smaller version of this project, namely setting up my christmas tree lights (on a prelit tree) to flash to music played on speakers. I was hoping you could tell me how I could alter your project to work (if it's even possible), what items I would need from your list, etc. Also, I wanted to know, if I were to successfully make my idea a reality, is it still possible to set my lights back to run normally, without the arduino & such attached? I hope you can help me! Thanks!

author
MRedmon made it!(author)2012-10-25

It's possible with no modification - instead of plugging an FM transmitter into the music shield, just plug in powered speakers (such as those made for computers). To make your lights run "normally" you could just unplug them and plug them into a power strip. You could also leave everything plugged into the controller but re-flash the Arduino with a new program that just leaves the lights on constantly. If you wanted to do that, you could flash Christmas_Lights_2010_Channel_Test.pde from Step 6 but change the loop to read:

void loop() {
for (int i = 0; i < channelsLength; i++) {
digitalWrite(channels[i], HIGH);
Serial.println(i);
Serial.print("On");
}

author
wirenut1980 made it!(author)2012-01-04

Great work! Looks Awesome!

author
MRedmon made it!(author)2011-12-14

Got my lights up last weekend and finished hooking up the lighting controller today. I still need to play around with the code a bit but at least everything is up and working.

CRW_0184.JPG
author
MRedmon made it!(author)2011-12-15

I was messing around with the settings... I think I'll probably put them back to the old settings.

http://www.youtube.com/watch?v=JdZwBIdWHvA&feature=youtu.be



author
GoranUvDenRimboe made it!(author)2011-11-27

Okay, I must be doing something wrong. I built the circuit using the larger Triacs (4A 400V) and for some reason the lights just don't blink. They just stay lit. On every channel just on never off. I've tried the test sketch with the same results. Lights on, never off. Is it possible I've mis-wired something? Is the pin layout on the larger Triacs different than the ones you used? The Christmas Sketch loops through the SD card nicely and plays all of the songs, but no joy on the lights. Any ideas where I screwed-up?

Thanks!

author
merkidemis made it!(author)2011-12-13

I am having the same issue with my board. All the channels but one stay on. Did you ever get yours figured out? (I used the same parts as the MRedmon)

author
MRedmon made it!(author)2011-12-13

Have you tested the AC side with a multimeter? Can you post photos (especially close-ups of the triacs and optocouplers)? What happens if you (safely) short pins 4 and 6 of the optocoupler?

author
MRedmon made it!(author)2011-12-13

Sorry... I meant short pins 5 and 6 of the optocoupler. I forgot that the order goes: 6 4 5

author
merkidemis made it!(author)2011-12-14

Here are the images (Warning: 18 megapixel)
Front:
http://www.redlightning.net/front.jpg
Back:
http://www.redlightning.net/back.jpg

The pins on my optocoupler are thus (Mouser lists the one in your how-to as obsolete):
1 6
2 5
3 4

Datasheet is here:
http://html.alldatasheet.com/html-pdf/53864/FAIRCHILD/MOC3031M/407/1/MOC3031M.html

Given that, which pins should I short?

author
MRedmon made it!(author)2011-12-15

The photos look good... I don't see anything questionable. You could short pins 4 on your optocouplers to check that the high voltage side is working correctly. If it isn't then I'd try turning one of the TRIACs around (swap the pins going to the optocoupler and out to the lights but keep the gate pin going to the optocoupler).

author
MRedmon made it!(author)2011-11-27

Hmm... that sucks. The 4A triacs should be controlled the exact same way as the ones I used. Can you post photos of the circuit (front/back)? The first thing I would do is check and see what the voltage is between ground and the Arduino outputs for each channel (a mis-wire could lead to voltage being applied across the channels at all times, regardless of which channels are being turned on/off on the Arduino). You could also run the following program (untested):

int channels[]={6,7,8,15,16,17,18,19};
int channelsLength = 8;

void setup() {
Serial.begin(9600);
for (int i = 0; i < channelsLength; i++)
pinMode(channels[i], INPUT);
}

void loop() {
for (int i = 0; i< channelsLength; i++) {
int channel = channels[i];
int sensorValue = digitalRead(channels[i]);
Serial.print("Channel ");
Serial.print(channel);
Serial.print(" reads ");
Serial.print(sensorValue);
Serial.print(". ");
Serial.print(10, BYTE);
delay(1000);
}
}

author
GoranUvDenRimboe made it!(author)2011-11-30

I found a pinout for the 4A triacs. From left to right counting the pins, pin 3 is the gate. I had at first wired pin 2 to the optocoupler thinking it was the gate. I've gone through and resoldered the triacs making pin 3 go to the optocouplers. However now nothing turns on.

I've attached images of the front and back of the pcb.
I added a third ground wire since my plug used the third gound.
So I've also added an extra wire block to handle the extra ground wire.
I also ran the plugs for the lights to actual outlet plugs.
The four plugs fit nicely in a four gang box and the green common ground from all of the plugs goes to the new ground block.

The common wire for the plugs is red and that goes to the wire block where the plug is attached. The black wires all run to the gang box to connect each single plug socket.

Thanks for the assist.

Steve

PCB_front.jpgPCB_back.jpg
author
MRedmon made it!(author)2011-12-02

I can't see any reason why it shouldn't be working. Have you been able to determine whether the optoisolators are switching correctly? What happens if you (safely) short pins 4 and 6? Is there voltage between neutral and the A1 of each TRIAC? Do both pins 1 (A1) and 3 (G) connect to the optoisolators? Is there voltage between pin 2 (A2) and neutral? After having it plugged in for a while and then unplugging it, is there a component that feels hot?

author
MRedmon made it!(author)2011-12-13

Sorry... I meant short pins 5 and 6 of the optocoupler. I forgot that the order goes: 6 4 5

author
GoranUvDenRimboe made it!(author)2011-12-05

I had a thought as I was checking things with the multimeter. Is it possible that the circuit just isn't sending enough of voltage to trigger the Triacs? Since I used the upgraded ones you mentioned and not the ones you first used to build with, that is about the only thing that makes sense. I tried to look at the specs pdf at mouser but I get a file not found error. So I'm wondering if that is what the problem is. When you measure the trigger voltage what do you get for a reading?

author
MRedmon made it!(author)2011-12-07

Datasheet:
http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00001570.pdf

Minimum trigger voltage for the Z0405 TRIAC is 1.3v so I don't think you should have a problem there (the Arduino is operating at 5v).

author
MRedmon made it!(author)2011-12-12

Just to be certain, I measured it... I saw a max of 4.7v on my multimeter.

author
MRedmon made it!(author)2011-12-13

It may or may not help the two people having problems but as a test I have hooked up one of the 4A TRIACs as an example in a breadboard to make sure everything is working as expected (and it does). I've attached 2 photos and the video of it working can be found at:
http://www.youtube.com/watch?v=Hu9v9kodvyk

2011-12-13 19.40.46.jpg2011-12-13 19.40.59.jpg
author
kate5593 made it!(author)2011-12-07

Hi Matt,

This project is great. I would like to apply it to lighting just our indoor Christmas tree. I'm a newbie so I'm not sure how to streamline the project. If I were to use just 3-4 sets of lights, what would I cut out as far as other parts? Thanks so much for any advice you can offer.

author
MRedmon made it!(author)2011-12-07

Instead of getting 8 of each of the following you could get 3-4 (as many sets of channels as you would like):

MOC3031 Optocoupler
Z0103 TRIAC
Both resistors mentioned above

You could also do away with the fm transmitter and hook up a powered speaker instead.

In Christmas_Lights_2010.pde change the following:

int channels[]={6,7,8,15,16,17,18,19};
int channelsLength = 8;

to:

int channels[]={16,17,18,19}; // or other 3-4 inputs that you want to use
int channelsLength = 4; // or 3 if you only want 3 channels

author
kate5593 made it!(author)2011-12-10

Thanks so much for your quick response. I'm still gathering parts. So if I end up with 4 channels, is that 10 wire terminals?

And one more rookie question: can I substitute a different optocoupler for the ones you specified above? That part seems to be on backorder for the suppliers I looked at.

Thanks again.

author
MRedmon made it!(author)2011-12-12

You sure can. Any optocoupler that can be triggered by 5V or less with 20mA of current or less and can handle the AC at whatever voltage you are using (110/220/etc) will work, I believe. Of course, if you want the same one, Mouser has them in-stock:

http://www.mouser.com/Search/ProductDetail.aspx?R=512-MOC3031-M

author
squirtdad made it!(author)2011-11-23

ok I am not an electronics guy but I am trying. Where is the FM transmitter connected.....for the life of me I don't see it. Also could you use the same connection for a simple jack and then plug the output into speakers?

thanks

author
MRedmon made it!(author)2011-11-23

In the upper-right photo in Step 1 you can see a headphone/speaker cable plugged into the jack that the FM transmitter would plug into (it's black and rectangular). You could also plug in speakers to it (you'd probably need amplified speakers).

author
robotjam made it!(author)2011-01-17

MRedmon, I was wondering if there were a way to add 1 normally open pushbutton switch to advance to the next song on the SD card. For example lets say that I have 15 songs on the card and I want to listen to the 7th song, as it is setup right now I woulld have to listen to the first 6 songs to get to the one I want, I think it would be nice if I could just push a button 6 times to advance through the first 6 tunes and play the 7th tune, the one i want to hear and see at that moment.
Also would there be a way to add some sort of potentiometer to the circuit to adjust the sensitivity? Like attach it to the common ground wire or something.
Sorry to keep bugging you about this but I think we could make this thing really cool (not that it's not now), I think I have some good ideas but I just have no idea on how to implement them.

author
MRedmon made it!(author)2011-10-19

I don't see why you couldn't do that... I haven't gotten back into the Arduino frame of mind just yet but glancing at the code make it seem like you could connect D0/D1 (can't be used if you are using serial communication like in my example sketch) or D9 to the normally open push button switch.

I don't see any reason why you couldn't replace the 1.5K resistor from A0 to R7 with a potentiometer. Maybe a 6k pot? You might just have to experiment. It could probably be done in software somehow, too.... perhaps another push button to switch between a given number of preset sensitivity levels (though you are limited in the number of inputs available... you'd have to give up serial communications or add a shift register if you wanted 2 push button switches... but with a shift register you could a LOT more channels).

author
mojarabm2 made it!(author)2011-05-26

Buddy , lets check out your design again,
why did you draw connectors as common between two triacs?
i can not understand ! let me know about your imaged , or i would show other ways to you , then you may love to make it better.
mojarab@hotmail.com

About This Instructable

112,525views

269favorites

License:

More by MRedmon:Making a Light Box, Version 2Christmas Lights to Music Using ArduinoTurn Your 12V DC or 85-265V AC Fluorescent Light To LED - Part 2 (External Appearance)
Add instructable to: