loading
If you liked this instructable, consider checking out my new website www.TheSiliconJunkie.com

You've probably seen all those videos where people make there christmas lights dance to music, you think to your self wow that looks realy cool.... i could never do that. WELL... you can the idea is actually quite simple.
WHATS A RELAY?
a relay is a component that can be used to control large amounts of voltage or current with just a small voltage, it does this by using that small voltage (5 volts in our case) to create a magnetic feild that will pull a switch type object to connect the larger current (120 volts in our case). Image 2 is a diagram on how a relay works





Step 1: Supplies

• 1x Arduino
• 1x Protoshield/ breadboard
8x 5v DC relays »»»  search.digikey.com/scripts/DkSearch/dksus.dll
• 8x 1N4004 diodes »»» search.digikey.com/scripts/DkSearch/dksus.dll
• 8x 2N2222 transistors »»» search.digikey.com/scripts/DkSearch/dksus.dll
• 8x 1K (Brown,Black,Red) ohm resistor (radio shack)
• 1x double/single sided PCB (radioshack)
• 1x sharpie
• 16x nuts and bolts (discuss size later)
• 8x dead sets of lights (for there male plugs)
• 500 ft of 5 strand cable
• a set of connector things
• some wire and some other stuff that you should have
• a place to display your light show
• and a some what knowledge of making pcb's

LETS BEGIN SHALL WE


<p>Actually, I just wrote this for Jingle Bells. I added a speaker to play the music, and wrote it into functions to cut the size down.</p><p>Chris H</p><p>***copy below this line and paste directly into a new Sketch****</p><p>int noteA = 2;<br>int noteB = 3;<br>int noteC = 4;<br>int noteD = 5;<br>int noteE = 6;<br>int noteF = 7;<br>int noteG = 8;<br>int beat = 9;<br>int spkr = 10;</p><p>int w = 2500;<br>int h = 1250;<br>int q = 625;<br>int e = 312;<br>int s = 156;<br>int ts = 78;</p><p>int midC = 262;<br>int midD = 294;<br>int midE = 330;<br>int midF = 370; //sharp<br>int midG = 392;<br>int upA = 440;<br>int upB = 494;<br>int upC = 523;<br>int upD = 587;<br>int upE = 659;<br>int upF = 740; //sharp<br>int upG = 784;</p><p>void setup(){<br> for (int x = 2; x &lt; 11; x++) {<br> pinMode(x, OUTPUT);<br> }<br>}</p><p>void loop(){<br> for ( int x = 2; x &lt; 10; x++) {<br> digitalWrite(x, HIGH);<br> delay(e);<br> }<br> <br> for ( int x = 2; x &lt; 10; x++) {<br> digitalWrite(x, LOW);<br> }<br> // measure 1<br> playBeat( noteD, midD, e );<br> play( noteB, upB, e );<br> play( noteA, upA, e );<br> play( noteG, midG, e );<br> playBeat( noteD, midD, q+e-10 );<br> delay(10);<br> play( noteD, midD, ts-10 );<br> delay(10);<br> play( noteD, midD, ts-10 );<br> delay(10);<br> <br> // measure 2<br> playBeat( noteD, midD, e );<br> play( noteB, upB, e );<br> play( noteA, upA, e );<br> play( noteG, midG, e );<br> playBeat( noteE, midE, q+e );<br> delay(e);<br> <br> // measure 3<br> playBeat( noteE, midE, e );<br> play( noteC, upC, e );<br> play( noteB, upB, e );<br> play( noteA, upA, e );<br> playBeat( noteF, midF, q+e );<br> delay(e);<br> <br> // measure 4<br> playBeat( noteD, upD, e-10 );<br> delay(10);<br> play( noteD, upD, e );<br> play( noteC, upC, e );<br> play( noteA, upA, e );<br> <br> digitalWrite(noteB, HIGH);<br> digitalWrite(beat, HIGH);<br> tone(spkr, upB, q);<br> delay(q);<br> digitalWrite(beat, LOW);<br> digitalWrite(noteG, HIGH);<br> tone(spkr, midG);<br> delay(q);<br> digitalWrite(noteB, LOW);<br> digitalWrite(noteG, LOW);<br> noTone(spkr);</p><p> // measure 5<br> playBeat(noteD, midD, e );<br> play( noteB, upB, e );<br> play( noteA, upA, e );<br> play( noteG, midG, e );<br> playBeat( noteD, midD, q+e );<br> delay(e);<br> <br> // measure 6<br> playBeat( noteD, midD, e );<br> play( noteB, upB, e );<br> play( noteA, upA, e );<br> play( noteG, midG, e );<br> playBeat( noteE, midE, q+e-10 );<br> delay(10);<br> play( noteE, midE, e-10 );<br> delay(10);</p><p> // measure 7<br> playBeat( noteE, midE, e );<br> play( noteC, upC, e );<br> play( noteB, upB, e );<br> play( noteA, upA, e );<br> playBeat( noteD, upD, e-10 );<br> delay(10);<br> play( noteD, upD, e-10 );<br> delay(10);<br> play( noteD, upD, e-10 );<br> delay(10);<br> play( noteD, upD, e );<br> <br> // measure 8<br> playBeat( noteE, upE, e );<br> play( noteD, upD, e );<br> play( noteC, upC, e );<br> play( noteA, upA, e );<br> playBeat( noteG, midG, q+e );<br> delay(e);<br> <br> // measure 9<br> playBeat( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, q-10 );<br> delay(10);<br> playBeat( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, q-10 );<br> delay(10);</p><p> // measure 10<br> playBeat( noteB, upB, e );<br> play( noteD, upD, e );<br> play( noteG, midG, e+s );<br> play( noteA, upA, s );<br> playBeat( noteB, upB, q+e );<br> delay(e);</p><p> // measure 11<br> playBeat( noteC, upC, e-10 );<br> delay(10);<br> play( noteC, upC, e-10 );<br> delay(10);<br> play( noteC, upC, e+s-10 );<br> delay(10);<br> play( noteC, upC, s-10 );<br> delay(10);<br> playBeat( noteC, upC, e );<br> play( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, s-10 );<br> delay(10);<br> play( noteB, upB, s-10 );<br> delay(10);</p><p> // measure 12<br> playBeat( noteB, upB, e );<br> play( noteA, upA, e-10 );<br> delay(10);<br> play( noteA, upA, e );<br> play( noteB, upB, e );<br> playBeat( noteA, upA, q );<br> play( noteD, upD, q );<br> <br> // measure 13<br> playBeat( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, q-10 );<br> delay(10);<br> playBeat( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, q-10 );<br> delay(10);</p><p> // measure 14<br> playBeat( noteB, upB, e );<br> play( noteD, upD, e );<br> play( noteG, midG, e+s );<br> play( noteA, upA, s );<br> playBeat( noteB, upB, q+e );<br> delay(e);</p><p> // measure 15<br> playBeat( noteC, upC, e-10 );<br> delay(10);<br> play( noteC, upC, e-10 );<br> delay(10);<br> play( noteC, upC, e+s-10 );<br> delay(10);<br> play( noteC, upC, s-10 );<br> delay(10);<br> playBeat( noteC, upC, e );<br> play( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, e-10 );<br> delay(10);<br> play( noteB, upB, s-10 );<br> delay(10);<br> play( noteB, upB, s );</p><p> // measure 16<br> playBeat( noteD, upD, e-10 );<br> delay(10);<br> play( noteD, upD, e );<br> play( noteC, upC, e );<br> play( noteA, upA, e );<br> playBeat( noteG, midG, q+e );<br>}</p><p>void play(int light, int note, int length ){<br> digitalWrite( light, HIGH );<br> tone( spkr, note );<br> delay( length );<br> digitalWrite( light, LOW );<br> noTone( spkr );<br>}<br>void playBeat(int light, int note, int length ){<br> digitalWrite( light, HIGH );<br> digitalWrite( beat, HIGH);<br> tone( spkr, note );<br> delay( length );<br> digitalWrite( light, LOW );<br> digitalWrite( beat, LOW );<br> noTone( spkr );<br>}</p>
<p>may i ask how did you connect the speaker.? please reply asap. thank you!</p>
So.... I have the controller working through a headphone output and would really like to tap into my speakers on my porch. I'm a bit hesitant to hookup the speaker output into the Arduino. Not really keen on what the different &quot;levels&quot; are. What is it that I need?
Got all my supplies. How do you wire up the Arduino? There's not really an explanation here or I missed something.
<p>I made a Christmas light controller similar to this one. But, I have a mp3 shield ready to use (and my music file too). I have been looking everywhere for a piece of coding to make it start and stop at the beginning and at the end of the code. Any one have the piece of coding I need? Thanks!</p>
what shield do you have? I'm looking for a compatible shield
Dear Dany, Can I use simple 2N2222 black coloured transistor?
Can I use this transistor?<br>
Yes you can. They are the same transistor in two different packages. The one he uses in this project has a TO-39 package. The one you want to use it a TO-92. :)
Thanks in advance
Can i use a 12v relay??????
Just want to say thanks! Followed your design and worked great. Set this up last Christmas(2011) to go with our christmas display.<br> <br> Boards and wires picture<br> <a href="http://i.imgur.com/3kqOE.jpg" rel="nofollow">http://i.imgur.com/3kqOE.jpg</a><br> <br> Video of the light show<br> <a href="https://www.facebook.com/v/10151069334010611" rel="nofollow">https://www.facebook.com/v/10151069334010611</a>
Also used vixen to create the sequencing.
<p>ok you create the sequencing on vixen, but you need to connect serial? or vixen give you the delay points to arduino code? I don&acute;t understand how you did it!!!, please let me know, thanks!!!</p>
In order to figure out delays for my project I used audacity. It is a free audio editor that allows you to see a point in a song down to the millisecond. Find two points where you want events to happen and subtract one from the other. That will be the delay.
<p>or you can use Vixen.. But i stick with audicity</p>
<p>when you play the music with the speaker, will it automatically start <br>the arduino light or you must start the arduino separately?</p>
<p>when you play the music with the speaker, will it automatically start the arduino light or you must start the arduino separately?</p>
<p>I've got an Arduino schematic and program that accepts audio to the analog in, then triggers various LED's for various frequencies in the music input. I'd like to add a relay board in place of the LED's, then run strings of lights off the relays. I believe the relay boards for Arduino have all the peripheral components of your circuit installed. In other words, I could buy a relay board with the correct operating voltage and already get the transistors, diodes, etc. Do you know if I'm correct? Thanks!</p>
Thanks for the fun learning experience
<p>thanks for the help thanks know can all of you help on lurning vixenLights not good at this and need some help thanks</p>
<p>thanks am trying it can not get to upload varify is ok</p>
<p>i need the one jingle bells can yoh help thanks john</p>
Awesome, If you go to do this again you can save money and time by buying the 8 relay board on amazon for $12... I got tired of making my own relay boards... Code works awesome.
Please provide the link?
<p>I'm guessing he is referencing this one:</p><p>http://www.amazon.com/Kootek-Channel-Module-Arduino-Raspberry/dp/B00C8O9KHA</p>
Hi <br>In the fashion of the Brits, we're ages behind in this sort of stuff but it is something I would love to have a play with. As I am a complete nooooob in all of this stuff, can I ask a silly question and hopefully get an answer? In part 3 making a pcb, there is a picture of the pcb fully soldered, any chance of putting labels on which soldered part represents which component? I'm having a hard time working out what the schematic should actually look like in reference to the top (if that makes sense). Cheers, Rob
After seeing another instructable similar to this I learned about the sainsmart relay modules. Everything is put together and it's cheaper than DIY.
Please provide the link.
The website is sainsmart.com and look for relay boards. I did however end up following this instructable rather than buying the pre made board because I wanted the experience. I did not however do the Copper board I used pre drilled breadboard and soldered the components together. It worked for the most part however I had some difficulty with my seeed studio music shield that I couldn't seem to work out
How did you connect 8 relays to only the 6 outputs the Arduino has?
I am by no means an arduino expert. I can tell you from my experience arduino has more than 6 outputs. It has something more like 14 digital pins however I don't remember exactly. 2 of them I never use. Pin 0 and 1 are the comm pins. The rest if the digital pins I believe are 3 to 13 which can be digital in or out. There are 6 analog I/O pins which I normally use for inputs. I have experience with the arduino uno, nano, and pro mini, which all have this same configuration. The best bet would be to check out the arduino website to be sure.
Can I solder instead of etching? The voltage supply in my country is 220V 50Hz. Will the solder take so much current?
Just wondering, instead of using crimps and vinyl electrical tape, why didn't you use wire nuts? They do make wire nuts that are designed to withstand the harshness of the outdoors.
Did you bring power in to your relays from 1 power outlet (wall socket) or multiple? Is there a problem running that many lights on one circuit?
Here is my setup so far. Arduino nano controlling LEDs which represent the relays, also controlling an Arduino UNO with an mp3 shield
Thank you for this tutorial. I am in the breadboard stage of my build. I will be using the relay circuit with an arduino as you demonstrated. My variation however uses an MP3 player that is also controlled by the arduino. This allows for the music and the light sequence to be played in sync every time. Unfortunately because I want events to happen at specific times I have to write the delays out in the sketch as you did. I will also have multiple songs each with its own individual sequence. I hope to include pics and videos soon.
Hi! Was the 120 volts based on your socket voltage? What if we have 220V? Thanks!
Your project is fantastic but i was looking to do it with a different song and i was wondering if there was any particular way you worked out the delays? (maybe a push button you tap to the beat and records the delay?)
I took a sort of brute force and ignorance approach. I simply sat down and played the song, and wrote out all the delays by hand. The down side to this is that i really can't play the music through speaker or something, so all i did was overlay it onto the video.
Hello dany32412, <br> <br>I'm 100% new to Arduino world but I would like to enhance my Christmas yard display I have been building the display for 30 yrs and now that I have retirement time I thought I would look into making the display a little more active. <br>I like your project for Christmas Light Controller and the addition of the Vixen Software. <br>I&rsquo;m not sure which Arduino you used ? <br>When I look at the Arduino UNO it indicts 6 outputs and your project uses 8 ports ? unless I&rsquo;m reading the spec sheet wrong. <br>I have just entered the world of programming a PIC for a baseball scoreboard and now I have time to look into the world of Arduino. <br>John <br>
Hopefully someone will still this even though its been awhile. I'm trying to hook up some christmas lights to my arduino using your same circuit schematics. When I hook it up on the breadboard the relay clicks for when the blinks should occur but the lights do not blink or go on at all. Any ideas for what's going on?
sorry for the late reply.Do the lights light up when you short the terminals you connected to the relay, If they don't then they are not powered correctly, if they do then there is a problem with the relay/relay board
Out of curiosity, have you thought of ways to dim the lights? I am fairly new to the Arduino platform and electrical engineering in general, but would it be possible to use some sort of digital potentiometer instad of the relays? <br><br>If not, do you have an ideas on how to easily dim the lights?
I would say that you can't dim incandescent bulbs (like the ones i used), but you could probably dim the new LED ones. You could swap out the relays for some high powered transistors, and send some PWM (Pulse Width Modulation) signals to it. I'm not sure if that would work or not, but theoretically it should. If anyone knows more about this, or can disprove me, please post.
Yes, you can dim lights as well as LEDs by using PWM. The only thing intrinsic to this project that would require a rethink is that relays aren't suited for driving PWM circuits. You would have to consider solid state switching options using something like a transistor or FET. For switching higher voltages it's a good idea to use opto-isolation to the uC.<br>

About This Instructable

253,404views

438favorites

License:

More by dany32412:NES in a Cartridge Homemade Notebook Dividers Arduino Christmas Light Controller 
Add instructable to: