Re: newbie q on controlling lights
I assume you're attempting some kind of home-automation project?
Building custom AC-Mains powered gadgets is dangerous enough, but trying to bury them in a junction box for semi-permanent installation is really asking for trouble, so it would be irresponsible of me to explain how.
Please- Just don't do it. Especially if you are a Newbie.
That being said, a lot of folks (myself included- I would be happy to share the details) have used commercial home-automation devices like X-10 receivers for controlling lights and banned. They are available for permanent installation, or as plug-in modules. They are already manufactured to meet safety requirements (e.g. U.L. in the United States) and there is no need to modify the receivers.
I use an Arduino connected to an X-10 PSC05 Power-Line interface, which is a completely isolated device for custom developers. It was a really fun project, allowing me to automate my lighting manually, or under the control of a real-time clock for automatic operation.
X-10 is kind of yestertech, so plenty of hackers are playing with Insteon and Zigbee devices, which are more advanced. The end-point receivers are a bit more expensive than X-10, however.
Sorry to be such a wet blanket about this, but I am very serious. I'd hate for you to burn your house down.
In any case, good luck-- there are a lot of really cool, challenging Home Automation gadgets that you can build- safely!