Arduino hangs when working with relays and AC

Hi, This is a common problem,

I suggest you read THIS PAGE.