Hi There,
You better use the circuit diagram in #8.
I attempted the circuit. I have enclosed pictures but will describe as best as possible
arduino pin 6 -> 470 resitor to base of transistor, with left pin leading to ground and right pin leading a common line which splits off into 1 pin of relay (of the 3 pins), the other is a diode pointing towards a line that is fed 5v from an external power source. This is repeated for pin 7.
I then used the script your provided, no clicking noise when hot is not attached and no switching when it is.
I feel i have possibly confused myself somehow and done things wrong. The bit that worries me the most is around the input area. I have attached pictures to attempt to assist my explanation.
Thank you