
If you are looking for extra protection you could use an optoisolator between the Arduino and the transistor. A rectifier diode like the 1N4001 or SB560 should do the job. We will need a diode fast enough to react to the kickback, and strong enough to take the load. But when that voltage spikes comes flowing the opposite direction, the diode allows it to flow back to the coil and not the transistor. So this diode (only allows current to pass one way) is normally facing the wrong direction and does nothing. This only lasts a few microseconds, but it is enough to kill our MOSFET.

What happens is when you stop powering the coil, a reverse voltage, up to several hundred volts, spikes back. Any time you are powering a device with a coil, such as a relay, solenoid, or motor, you need this guy, and don't leave home without it.

You can see that in 2 of the 3 illustrations, there is a diode parallel to the device we are powering. You don't want this pin to ever be floating as it will trigger on and off. This is here incase the arduino comes loose, or the wiring is bad it will default to off. The resistor holds the gate low when the arduino does not send a high signal. The only part that looks funny is the resistor. Hooking it up / What's the diode used for? Pete over at Sparkfun put out amazing video explaining MOSFETs for a solid 20min. If you want to know more, or actually know what is actually going on in there. When our arduino sends a HIGH signal to the transistor's gate, it switches the transistor (connecting the drain and source) and completes the circuit for the motor, solenoid, or light. Ground is connected to the transistor's drain. So we connect it so that our motor, solenoid or light is connected to V+ but not ground (V-).

When you send a HIGH signal to the gate (control pin), the transistor switches and allows current to flow from the source (in) to the drain (out). You basically have an In called the Source, an Out called the Drain, and a Control called the Gate. If you don't know transistors at all, they are 3 lead components that have 2 simple functions, to switch or amplify (in this example it is setup as a switch). it is here in an attempt to explain, in simple terms, what is going on.įirst off, a MOSFET is a transistor, just a special kind. WARNING: I am about to simplify the crud out of this, so beware. but you can use any N-Channel MOSFET exactly the same way. Today we are going to talk about another way of doing just that, this time with an N-Channel MOSFET metal–oxide–semiconductor field-effect transistor, specifically the RFP30N06LE MOSFET (You can pick these up from sparkfun). Eventually you are going to find yourself holding a 12v solenoid, motor, or light and wondering "How the heck am I supposed to control this from my Arduino?" And we have covered this in the past.
