user26670: I want to use a transistor to turn on and of an electric magnet, I have hooked up a transistor like this: 

simulate this circuit – Schematic created using CircuitLab
The blue wire goes to the magnet and the white wire goes to the ground:

Regardless of if the arduino is on or off(I can even unplug port 12 from the arduino, the magnet is still on, the circuit never closes. What do I need to do to make the transistor turn off?

user368: Darlington transistors are very sensitive; even putting your hand near it can be enough to turn it on. Either tie the base to ground with a large resistor or switch to a MOSFET with its gate tied to ground through same. In either case put a diode backwards across the coil to absorb the energy from the coil when it de-energizes so that the transistor is not damaged.

26670: <p>I want to use a transistor to turn on and of an electric magnet, I have hooked up a transistor like this: </p>



<p><img src="https://i.stack.imgur.com/VOnA0.png" alt="schematic"></p>



<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fVOnA0.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>

<p>The blue wire goes to the magnet and the white wire goes to the ground:</p>

<p><a href="https://i.stack.imgur.com/9RB2M.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9RB2M.jpg" alt="enter image description here"></a></p>

<p>Regardless of if the arduino is on or off(I can even unplug port 12 from the arduino, the magnet is still on, the circuit never closes. What do I need to do to make the transistor turn off?</p>
 368: <p>Darlington transistors are <em>very</em> sensitive; even putting your hand near it can be enough to turn it on. Either tie the base to ground with a large resistor or switch to a MOSFET with its gate tied to ground through same. In either case put a diode backwards across the coil to absorb the energy from the coil when it de-energizes so that the transistor is not damaged.</p>
