Instructables

3 Channel arduino Powered Christmas Light Controller!

Featured
Picture of 3 Channel arduino Powered Christmas Light Controller!
For Christmas this year, I wanted to make a really cool project but didn't quite know what to make. As I was getting the Christmas lights out to decorate, there was an old busted Christmas light timer. I took it apart and looked around at the low-voltage circuit. Before this I had never experimented with AC circuits. I decided instead of hacking the timer to just make a whole new circuit, thus starting the AC electronics hobbyist side of me. And here it is, the 3 channel arduino powered Christmas light controller!


CAUTION!! If you decide to build this project you must be CAREFUL! This project is built with AC voltage which CAN BE DEADLY! If you have never worked with AC before, please get supervision from someone that has. Instructables and/or myself are NOT responsible for any injuries caused by the misuse of this project.


If you need any help or perhaps a more detailed description of the schematic, leave a comment.





 
Remove these adsRemove these ads by Signing Up

Step 1: Tools, Materials and Skills

For this project you will need the following tools, materials and skills:

TOOLS:

Soldering iron- you can get one of these for cheap at radioshack or online

Solder- can also be bought at radioshack

Wire cutters and wire strippers- radioshack has them

Something to mark with- I used a sharpie

Sand-paper




MATERIALS:

3, 5 volt relays- I bought mine at radioshack but they can also be bought for cheap online

3, 1N914 diodes

3, NPN transistors- I used 2n3904 but 2n2222 will also work.

Solid and Stranded core Wire- radioshack

Perforated board A.K.A. proto-board- radioshack

male and female header pins- online

Arduino microcontroller- I used an UNO but older versions will also work. You can buy them online and at some radioshacks

Electrical Cord- radioshack or home-improvement store

Electrical outlets- home improvement store or radioshack

electrical tape




SKILLS:

For this project you will have to know how to do the following:

Solder

Read schematics

Work with AC volatge

Have basic knowledge of electronic circuits

how to program and arduino

Step 2: Make the Shield for the Arduino

This project will have two circuit boards, one that goes on top of the arduino like a shield and one that connects the relays to the arduino through wires. To make the shield, take a piece of proto-board and mark it with a pencil or sharpie so it lines up with the arduino. After you mark it, score it with an x-acto knife. After you have scored it 5 or 10 times snap it at the scored line. Take a piece of your sand paper and stick it to a block of wood. Sand the edges of the board to make it neater. Push the leads in the header pins so they are flush with the plastic, then solder them to the board. Cut a row of 5 female header pins and solder them somewhere on the board. connect them to 5v, GND, digital pin 13, digital pin 12 and digital pin 11.  Continue to the next step.

Step 3: Make the Relay Board

Following the schematic above, solder your relays, transistors and jumper wires onto the board. Solder a diode between the coil leads of each relay. Solder all of the 5 volt lines together ultimately coming down to a single stranded core wire. Also, solder a stranded core wire to each of the base's of the transistor. Finally, connect all of the emitters together and solder a stranded core wire to the connected emitters. These 5 stranded wires now need to be soldered to 5 header pins. This will connect to the female header pin on the shield we made on the last step. Finally, connect the hot wire of the electrical cord to the hot side on all of the outlets. Connect the neutral side to the throw of the switch in the relays. If you don't understand this explanation refer to the schematic above or leave a comment!

Step 4: Program the Arduino

The following code will cycle through turning on each relay:

void setup() {

pinMode(13,OUTPUT);
pinMode(12,OUPTUT);
pinMode(11,OUTPUT);
}

void loop() {

digitalWrite(13,HIGH);
delay(900);
digitalWrite(13,LOW);
delay(900);
digitalWrite(12,HIGH);
delay(900);
digitalWrite(12,LOW);
delay(900);
digitalWrite(11,HIGH);
delay(900);
digitalWrite(11,LOW);
delay(900);
}
danielemur2 years ago
Would it be possible to use this circuit with light switches instead? I dont mean the ones on the light itself, but the wall switches.
Robot Lover (author)  danielemur2 years ago
This is definitely possible. There would be two ways to do that. You could directly connect the light switches to the circuit, or you can mount a servo to each light switch that flips the light switch so you don't have to open up the wiring in your wall.
klaurens2 years ago
In SA we use 220-250V, what relays would I have to use for that amount of voltage?
Robot Lover (author)  klaurens2 years ago
Most 5 volt relays are most likely not rated for that much voltage. Your best bet (to my knowledge) would be to use TIP120 transistors instead of the 2n3904's and use 12 volt relays instead of the 5 volt ones. It would probably be best for you to contact someone that has experience with that kind of voltage (Mine is 110). Remember to be safe, never work on a mains voltage projects while it is plugged in, and to insulate ALL live wires using electrical tape. Have fun!
Thanks man, do you know anyone on instructables that I could ask??
Robot Lover (author)  klaurens2 years ago
If you are really set on making this project, you can't go wrong with asking a question. Again, I do not feel comfortable giving people advice with mains voltage circuits because they are not my specialty. I will do a bit of research and consult my father (he is pretty good with mains voltage).
Dstrcto2 years ago
Most relays have contact ratings... are these rated for 120VAC?
Dstrcto Dstrcto2 years ago
Nevermind, I found info on the contacts 125VAC @ 1A. Gotta watch the amperage or you'll weld the contact.
fjordcarver2 years ago
Way to go!!! You are on Hack-A-Day!!!
http://hackaday.com/2011/12/18/controlling-your-christmas-lights-without-ever-getting-off-the-couch/
Cheers!
Robot Lover (author)  fjordcarver2 years ago
Life long dream fulfilled! I am happy!!
Henry_Best2 years ago
Your scematic doesn't show any loads on the AC lines, which means that as each relay closes it will cause a dead short across the AC supply! Noobs to AC might not know this, with disasterous results!
Robot Lover (author)  Henry_Best2 years ago
Thanks for pointing this out! I actually thought I updated the schematic but I guess it didn't upload properly. Thanks for the comment!
You're welcome.
hcaz-3012 years ago
Then link it up to the internet or a timer, so the light turn on when your away from home
Robot Lover (author)  hcaz-3012 years ago
soshimo2 years ago
You might want to add a rectifying diode across the relay pins. When current stops moving through the coil (the adruino pin is brought low) you get a flyback effect which could smoke your android. Also a project encasement would be great - you can pick them up at radio shack for about 5-10 bucks depending on size (a definite requirement when working with mains voltage and current). Finally, you mention the npn transistors but I don't see you using them anywhere. Were you maybe thinking of using them as a current controlling device for the relay coils? Otherwise, great tut.
Robot Lover (author)  soshimo2 years ago
I was going to put a diode between the leads for suppressing the voltage transient, but I did not have the proper value(1N914). The relays that I used are pretty small that the chances of a voltage transient are slim to none, although it is a good practice to place the diode between the coil leads of a relay. At the time, I did not have enough time or money to buy an enclosure but do plan on buying one and updating the instructable. I had two schematics, one that had the transistors and one that had the outlets, I figured that the one with the electrical outlets was wiser to put on because the schematic clearly shows how to hook them up and the text describes how to hookup the transistors. The transistors turn on and off the external power to the relays. Thanks for the comment!
If it has a coil or any inductive part then it will create a voltage spike when you remove current. Inductors resist current change, so when you remove power from a coil and give the residual current no place to travel a voltage spike will form. By placing a diode "backwards" you give a path for the current to slowly fade. Here is a scope cap of a 5v I just tested without a diode, pk-pkv =183v.
InductiveVSpike_ce.png
Robot Lover (author)  SparkysWidgets2 years ago
Wow! Thanks for letting me know, I will put this in the tutorial and make sure to switch the schematic around ASAP. Thanks for the comment!
Not a problem at all :) I generally start with "fast" diodes like a 1n4148, but rectifiers like the 1n400X series work just fine too. Most pks I measure on those 5v relays are about 59v but, every once in a while they sure get up there. Luckily they are very short (IIRC that one was 147uSec).
Robot Lover (author)  SparkysWidgets2 years ago
I was trying to test the transient's voltage on my multi-meter but I guess it was way too fast for my meter. I really want a logic analyzer!
That scope cap was taken with a QuantAsylum100 we are evaluating for carrying in our shop. For a usb scope and analyzer I'm pretty impressed with it, but you cant go wrong with a hacked Rigol :) A scope is a very handy tool while not necessary, when you do get one, you'll wonder how you did anything without it :)
soshimo soshimo2 years ago
I meant "smoke your arduino", I have Android on my mind today.
canucksgirl2 years ago
Good idea Robot Lover. However I feel a heads-up call is warranted to my local fire department if I so chose to try this. - Electricity scares me. That and propane bbq's... Thanks for starting the Instructable Advent Calendar 2011 - I look forward to seeing all the entries. - oh what fun.
fjordcarver2 years ago
Great job!
Robot Lover (author)  fjordcarver2 years ago
Thanks!
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!