Step 16: Program

Plug in your USB cable, make sure that the switch on the Wireless SD board is toggled to "USB" and program the Arduino with the following code:

When you are done programming it, unplug the USB cable and toggle the switch back to "micro."
Very interesting project. I started to do something like this with battery powered xmas lights, freebasic. twidge, and the parallel port, but had other projects to work on. .
could you put in the arduino code.<br>
See step 16
(I'm posting this separately from the other comment so that the resulting threads are separate.)<br><br>As a side note, take a look at the &quot;ADC and digital I/O line support&quot; section of the XBee manual. The XBee could drive the transistors directly, making the Arduinos in this project entirely superfluous. The PC-side program would simply have to place the units into API mode and send the appropriate Dx commands. <br><br>Although if your PC doesn't have a UART (I see in the photo that it's a modern Mac), then using an Arduino as a USB-to-serial converter is a practical, albeit expensive, way to do it.<br><br>However, that's all splitting hairs. The project works, it's very well documented, and the photos are clear and plentiful. Nice writeup!
I'm concerned that the lack of snubber diodes on the relay coils means bad things for the drive transistors and potentially the Arduino itself.<br><br>Relay coils, like all coils, are inductive. When you place voltage across a coil, current starts flowing through it, building up a magnetic field in the coil. When you remove the source of current, that magnetic field tries to collapse, but the energy in the field has to go somewhere. It forces the current to continue flowing until the field is dissipated, raising the voltage if necessary. This effect is how switchmode power supplies work.<br><br>If you've turned on the current with a transistor, then when you turn the transistor off again, the voltage will spike until the transistor conducts anyway, damaging the transistor. Your circuit might endure a thousand on-off cycles before anything obviously bad happens, or it might smoke right away. When the transistor fails, the rest of the energy might get dumped into the Arduino.<br><br>To prevent this, put diodes in parallel with the relay coils, but orient them so that they're not normally conducting. When the coil de-energizes, the inductive kick is opposite in polarity, and it will flow harmlessly through the bypass diode, rather than beating up the transistor. It's essential to provide this free-wheeling diode on every relay or solenoid coil! Motors exhibit the same effect, btw.
Gee Whiz! Both of you &quot;electrical wizards&quot; are wrong!<br> <br> 1. If an outlet has a ground connector it MUST BE CONNECTED TO GROUND! Speculate all you want about the whys and wherefores but check yer NEC.<br> <br> 2. Polarized plugs and sockets MUST be wired correctly, the NEC does not care if it is a Christmas tree or an iron lung. The grounded conductor is WHITE or GREEN not black as shown in the pictures. Under no circumstances should a device like this cross up polarization IF the plug or outlets are polarized.<br> <br> 3. Any device that is going to be plugged in and cannot safely handle the&nbsp; current available for it's type of plug MUST have an overcurrent for protection against fire. In the case of this unit there needs to be a 2A fuse or circuit breaker on the hot wire before it connects to anything else in the box.<br> <br> 4. &quot;The polarized plug is just for people's safety.&quot; Yep, the most important thing when working with electricity is safety. I can't imagine why anyone wants to be dismissive of a guiding principal of good design.<br> <br> How to fix this:<br> <br> 1. Either use 2 hole outlets OR use a 3 prong cordset and connect the grounds on the 3 hole outlets in the pictures to the green wire in your cordset.<br> <br> 2. Use white wire on the neutral side of the outlets.<br> <br> 3. Wirenut the white wires to the ribbed side conductor of a 2 prong cordset OR the white wire of a 3 prong cordset.<br> <br> 4. Add a 2A fuse or circuit breaker between the hot wire on the cordset (smooth insulation or black) and the common conductor going to the relays.<br> <br> 5. The battery isn't the best touch. It is metal and that clip does not retain it very well. Besides you have to open the box for replacement... A better notion is to use a wall wart either inside or outside the box. I strip quite a few 5V USB supplies out and use them on PIXAXE projects. The cost is just about the same as a battery, clip and mounting hardware.<br> <br> Following these steps will make your project AHJ friendly and demonstrate that you know which end of a soldering iron to pick up. This is a mystery box to most people that will come across it after you are done. As such it should not present a hazard if used in a way you didn't intend.<br> <br> And yes, some current limiting resistors are a good idea between the PIC outputs and the transistor bases.
I love it! You should probably put a 1k ohm resistor limiting the current to the base of each transistor.
hey everyone post your tree's twitter handle so i can wake up on xmas and turn all your lights off/on/nutty
Awesome project, looks really neat and professional. Ive wanted to do something like this for years, but never thought of twitter integration. Truly ingenious, and much beyond my abilities, very good work. <br><br>However being an electrician, I just want to warn you of a few things. Your connections on the receptacles need a stak-on connector because their stranded (although that will work fine assuming no strands are moving around) but my major concern is the lack of a ground. Sure Christmas lights don't have them, but you never know what could happen, and I strongly recommend installing one. Or install receptacles that don't have a ground prong. And because your plugs are polarity specific, check your lines coming in. 110v on a neutral will destroy (sometimes violently) some equipment (as I learned when I modified a string of LED lights to fit in a non polarized plug, not pretty) Also, because you have 20A T-Slot receptacles, an your relays are only good for 2A, I recommend a 2A fuse for each plug, just to protect your kick ass project :) <br><br>I was also wondering why you opted for a 9V battery instead of an actual power supply such as a wal wart? It wouldn't be hard to place the transformer inside of the project box and connect 110v to it in there, so you still only have a lamp cord. <br><br>But Very good instructable. You covered every step thoroughly and made it easy for anyone to build this (which I'll be doing soon :)) keep the good ideas flowing and stay safe this Christmas.
<strong>@bobrigewitch</strong>&nbsp; When someone states that they have credentials in a certain area, it implies that the information they give is accurate and truthful. Since your post contains incorrect advice regarding electricity, I am compelled to respond to set the record straight.<br> <br> I happen to be an electronics engineer with electrical certification and 26 years in the industry. I will be as brief as possible, and will discuss only three of the assertions.<br> <br> <strong>Ground</strong> - Your &quot;major concern&quot; with the project not having a ground is unfounded. Many appliances and consumer goods do NOT have a ground, toaster, coffee maker, shaver, vacuum cleaner etc. As you pointed out, the Christmas lights have no ground - there is absolutely no benefit or added safety from including a ground. Since you &quot;strongly recommend installing one&quot;, please explain why.<br> <br> Do you know why the ground pin is longer than the two flat blades on a 3-prong plug? It's so that the equipment's safety (ground) is last to be disconnected when unplugged.<br> <br> <strong>Polarity</strong> - You stated &quot;110v on a neutral will destroy...some equipment...&quot;&nbsp;&nbsp;&nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <strong>***</strong>&nbsp; This is 100% dead WRONG&nbsp; <strong>***</strong> &nbsp;&nbsp;<br> There would not be a single piece of electrical equipment that would be harmed by having its neutral and &quot;hot&quot; terminals interchanged. With Alternating Current (AC) the polarity of plus-minus or positive-negative, is swapped back and forth 60 times per second. The only reason one terminal is designated as &quot;neutral&quot; is because it is electrically attached to ground at the distribution source that provides power to the building. The purpose of &quot;bonding out&quot; the neutral like that is purely for safety. Outlets/plugs with the larger slot/pin is to preserve this safety feature by creating a polarity scheme. For instance, a light fixture would have the shell of the socket connected to neutral in case someone's fingers touched the metal threads on the base of a lightbulb, in case the power was still on while changing it. Not all electrical devices make use of the polarity feature (it's optional) and you'll still see many plugs with same-sized blades. Polarised plugs are becoming almost the standard now, but that has more to do with plug fabrication reasons rather than the product's electrical requirement.<br> <br> <strong>Fuses</strong> - I do agree that 2A fuses would be handy for each outlet, but the reason is entirely for the protection of the 2A relays, NOT because of the capacity of the outlets. Again, MANY household items do not contain fuses (toaster, vacuum, lamps), but many electronic devices do in order to protect ultra-sensitive circuitry, but those are not replaceable by the user.<br> <br> My apologies for the long post, but people need accurate information when dealing with electricity.<br> <br> VERY nice instructable by the way - well thought out and well documented with excellent pictures. A pleasure indeed.&nbsp;&nbsp; ~Dave
I thank you for your criticism, I guess I wasn't clear enough on a few things, allow me to explain. <br><br>Ground - My concern with ground is that some appliances use a 3 prong plug, and those appliances have a ground because the engineer who designed it felt it should have one, and since his plugs have a 3 prong receptacle, it is possible that these grounded appliances would be plugged into this unit, therefore there should be a ground to accommodate for these circumstances. <br><br>Polarity - I agree 110v on the neutral and 110v on the hot will result in 0v potential, however incorrect polarity would mean there would be 110v on the neutral and 0v on the hot, resulting in 110v that is reverse bias. They design polarized plugs (one blade wider than the other) because some equipment can be harmed from this situation. <br><br>Fuses - your right, they would be more for the protection of the relays, however that directly corresponds to the load that can be placed on the relays. My idea was just &quot;2A Protection&quot;<br><br>I am new to this site and just thought I'd help. Also next time allow me time to defend myself instead of bashing my knowledge Dave. Merry Christmas. <br><br>
Actually, in AC, polarity doesn't matter to the circuit.&nbsp; AC is constantly switching polarity.&nbsp; The best way to describe it is to use the physics concept of &quot;frame of reference&quot;.&nbsp; A person's body is usually grounded.&nbsp; This means any voltages are relative to, or referenced to, ground.&nbsp; This means that to us it seems neutral is 0 volts and hot switches back and forth between 110 and -110 volts.&nbsp; The appliance is not referenced to anything, so to it, one wire is 110 volts higher than the other, and then they switch with each other.&nbsp; It doesn't know which is hot and which is neutral.<br> <br> The polarized plug is just for people's safety.&nbsp; Since people are referenced to ground, neutral is safe at 0 volts to us while hot is dangerous at between +110 and -110 volts.&nbsp; This way, engineers can make sure it is much harder for people to come into contact with hot wire than the neutral one since they know which will be zero volts relative to the user.
I guess your right there. Thanks for the clarification. Although my 'why' is wrong being sure of correct polarity still isn't a bad idea.
It totally says that this was submitted by radioshack on the great create website!
Very nice!
Sweet project as usual. I'm curious, why 2 arduinos and python rather than an ethernet shield or wifi shield. Also, thanks for using alot of easily accessible RadioShack parts. I'm kinda thinking that's why 2 arduino and a computer.
I tried to stick with easily accessible Radioshack parts ;-)

About This Instructable


44 favorites


Bio: My name is Randy and I run the Instructables Design Studio. I'm also the author of the books 'Simple Bots,' and '62 Projects to ... More »
More by randofo: Hard Candy Recipe 2-Ingredient Candy Teeth Candy
Add instructable to: