arduino hangs when connected to 220v supply through relay

Thanks to all. i solved the problem, its not hanging now. Thanks a lot.

Arrch: You can do it with a relay, transistor, diode and a resistor. You could even get a solid state relay and drop the transistor and resistor.

Ooops, Transistor will create problem in the circuit you said. and i tried it too. Optocoupler isolates two circuits which i exactly want.

Thanks for your suggestion.

jonyjakee: Optocoupler isolates two circuits which i exactly want.

So does a relay.