Switch a 10 A, 40 V Load
This is too much for our 2N3904. We could get a big power BJT (bipolar junction transistor), but then we would have to drive a lot of current through its base to turn it on, because the current through its collector would be so huge. We could try a Darlington BJT, which uses two transistors to deliver twice (β2) the current gain, but a FET will probably give better performance—less power dissipated in the switch for a similarly-priced part, and faster switching—than the BJT.
The FET is easy to use, because the gate draws no DC current. In theory, we can switch as many amps as we would like just by changing the gate voltage with our I/O pin. The circuit looks like this:
The concept is the same as when we used an NPN transistor. The resistor doesn't actually do anything at DC, because (unlike the NPN transistor's base) the n-FET's gate does not draw any current. The resistor helps to protect the micro from transients when the high current switches, though.
I specified an IRL3103PBF for the FET. I chose this FET because it will operate from a small voltage swing on the gate. Traditionally, power n-FETs were designed to operate with a voltage of 0 V (off) or 10 V (on) at the gate. We need something that will turn on fully from a much smaller voltage, so I chose a ‘logic-level FET,’ which is more or less fully on with 5 V on the gate.
Notice that we didn't have to choose a logic-level FET for the previous circuit with the p-FET. There, the gate swung between 0 V and 10 V, so we had plenty of gate voltage swing. It is because we are driving the gate directly here that we have to choose a bit more carefully. In fact, we could use a similar circuit with a 2N3904 to produce an 0 to 10 V gate voltage swing if we needed to, but it is easier to choose a logic-level FET.
The diode does the same job as before, and can be omitted for a non-inductive load. We could probably live without it regardless; the FET that we are using is rated for avalanche breakdown. If the drain-source voltage of any FET is brought past the rated VDSmax, then the FET will conduct from its drain to its source, independent of its gate voltage. In general this is bad, and may result in permanent damage to the part. The datasheet for the IRL3103 explicitly permits this mode of operation, though, and we can therefore take advantage of this.