**Please be careful when using mains voltage. Make sure you understand the risks and you are familiar with dealing with high voltage. It never hurts to use an RCD or an isolated transformer or many other devices or techniques that might save your life. Internet is free USE IT! In NO event shall I be held liable for ANY damages. **
This was a very old project i did in 2005 (when I was 16) before I even learnt programming. The aim was to have lights-devices of 240V controlled using a parallel port of a PC. A USB was not used, since back in the day it was a mysterious thing for me. If I were to redo this project I would use a uC connected with USB or through an ethernet chip bridge but still use the circuit below that converts a 5V signal to a 240V switch.
The TO-220 packages are the TRIACs, white DIPs are the isolators. Touching one of those will certainly electrocute you!
//more info and credit :
The circuit below is using TRIACs to go from a logic signal to a 240V switch. TRIAC is essentially a dual thyristor or a triode and it can only be used with alternating currents of any voltage. http://en.wikipedia.org/wiki/TRIAC
The circuit consisted of: PC signal -> opto-isolators -> TRIACs -> 240V bulbs
Why TRIAC? you ask. Semiconductor Relays are expensive, whereas a simple TRIAC and an optoisolated TRIAC driver, such as the MOC3041 from Motorola can still do the job quite nicely.
An optoisolator is a device which is used to keep low-voltage microprocessor circuits (such as the very delicate parallel port) and high-voltage (mains) apart. They generally consist of 1 or more Infrared LED's pointing at a detector. The detector is used to trigger the TRIAC or SCRs. Sometimes, as is the case with the MOC3041, there is a Zero-crossing detector also incorporated into the same package.
Which triac should I use?
Generally, to be on the safe side, choose a TRIAC which has more or less double your mains voltage rating. I.e. for 220V use a 400V TRIAC. Check out the pricing on TRIACs to see which choice is economical for you.
The software was a plugin for winamp that allowed the user to select the frequency responce for each bulb.
more info and credit :