How to switch lights (Mains power) with Arduino?

This is my first post, so I'm sorry if this is the wrong section.

I want to switch the light inside one of the lighted ceramic houses that people use for christmas displays on and off by using an arduino pin. However, in the United States, where I live, 120vAC is obviously beyond the capacity of an arduino.

  1. Would a relay work for something like this, or do they draw too much power to drive directly from a pin?
    1B. Are there better options than relays?

  2. What is the possibility of something going wrong and accidentally frying the arduino? Is it necessary to take precautions against this?
    2B. If so, what would you reccommend?

  3. I am planning on using a Mega2560 to activate these systems, because there are a lot of houses I want to control, if that makes a difference in the power distribution/control systems.

Would a relay work for something like this

Yes.

do they draw too much power to drive directly from a pin?

Possibly. However, you can turn a transistor on and have that turn a relay on. Sparkfun sells a relay kit with the needed transistor, resistors, etc. Or, get a powertail.

What is the possibility of something going wrong and accidentally frying the arduino?

Depends how careful you are.

Is it necessary to take precautions against this?

Well, duh!

I am planning on using a Mega2560 to activate these systems, because there are a lot of houses I want to control, if that makes a difference

It makes a difference in how many you can control, but in no other way.

do you have to use 120v lights. White LEDs are pretty bright, a lot easier to controll and much cheaper parts wise.
edit: and safer!

PaulS:

Is it necessary to take precautions against this?

Well, duh!

I was thinking more in the way of what sort of precautions ought to be taken, rather than if they should be.

Any suggestions on that would be appreciated.

groundfungus:
do you have to use 120v lights. White LEDs are pretty bright, a lot easier to controll and much cheaper parts wise.
edit: and safer!

while not technically necessary, I already have all of these (they came with the houses), and I thought it would be cheaper to leave them than to go for another system...

If getting all of these LEDs is significantly cheaper than staying with the bulbs, I could see myself changing over. (and finally not needing to have 5 power strips to run all of these :))

Yeah, this seems to be cheaper (relay+outlet box+safety precautions+etc really add up).

And LED's don't get hot. If you want to get fancy go with RGB LED's and light your houses in living color.

groundfungus:
And LED's don't get hot. If you want to get fancy go with RGB LED's and light your houses in living color.

Depends on the specific led. Those 1,3,10,etc watt leds do get hot and have to have proper heat sinking to prevent damage.

Lefty

I should know better than to generalise. Those higher power pieces are beyond my experience.

I'll probably be using these lights:

unless someone can find better lights or a reason not to use them.


anyway, heat is ok, given that the houses are ceramic, and I currently use incandescent bulbs.

though I doubt that these LEDs will, given their low power usage.

Check Amazon for 5mm white led. Much cheaper. 50 for about the same as 2.

lots on eBay
Note: LEDs need a series resistor.
http://www.ebay.com/itm/Pack-of-100-5mm-Clear-White-LEDs-Ultra-Bright-LED-/190421860749

thepenguin:
This is my first post, so I'm sorry if this is the wrong section.

I want to switch the light inside one of the lighted ceramic houses that people use for christmas displays on and off by using an arduino pin. However, in the United States, where I live, 120vAC is obviously beyond the capacity of an arduino.

  1. Would a relay work for something like this, or do they draw too much power to drive directly from a pin?
    1B. Are there better options than relays?
    Relays are your best options

  2. What is the possibility of something going wrong and accidentally frying the arduino? Is it necessary to take precautions against this?
    2B. If so, what would you reccommend?
    Possibilities always exist.
    you would need to optically isolate the relay side and the arduino side just to be safe, using opto couplers.
    you can always buy a relay module with opto couplers installed or make one. plenty of schematics available online

  3. I am planning on using a Mega2560 to activate these systems, because there are a lot of houses I want to control, if that makes a difference in the power distribution/control systems.
    which processor you use, doesn't really make a difference (imo) if your only objective is only to turn on/off lights even a uno would work, with slightly more circuitry.

on another note, led lights as opposed to bulbs will save considerable amount of power.

fuzail:
Possibilities always exist.
you would need to optically isolate the relay side and the arduino side just to be safe, using opto couplers.
you can always buy a relay module with opto couplers installed or make one. plenty of schematics available online

I would also assume that because LED lights are safer, cooler, and don't require dealing with nasty power supplies, opto couplers (as well as all the other protections necessary for 120vAC) become unnecessary.


I am worried about a potential issue with quality when buying from amazon or ebay, but those prices seem to be approximately what LEDs should cost before RadioShack inflates the price by a factor of ten...

I am worried about a potential issue with quality when buying from amazon or ebay, but those prices seem to be approximately what LEDs should cost before RadioShack inflates the price by a factor of ten...

I have purchased many, have never had any problems. Maybe I'm lucky.

If you have a bunch to control look into using shift registers to conserve pins and maybe PWM to create flickering candle effects. Merry Christmas