Switching Voltage of Transistors
I'll answer the more general question of how to switch a load on/off from a digital signal when the load requires current or voltage that the digital signal can't supply directly.

One very common and cheap way is to use a NPN load side switch:



R1 must be sized so that the maximum current the digital output can source when high is not exceeded.  For example, let's say that 3.3 V logic is used, and the maximum current source spec of the digital signal driver is 5 mA.  Figure the B-E junction of the transistor drops 700 mV, so that leaves 2.6 V across R1.  By Ohm's law: (2.6 V)/(5 mA) = 520 &Omega;, so we'll round up to the nearest common 5% value of 560 &Omega;.

Now you can work backwards and find the minimum base current.  Let's say the digital output is only guaranteed to be at 3.0 V at the full source current.  That leaves 2.3 V across R1, which could be as high as 588 &Omega;.  (2.3 V)/(588 &Omega;) = 3.9 mA.

Q1 must be rated to withstand whatever the power voltage is.  In your case, that's only 5 V, but this method works regardless of what it is, as long as the tranistor can handle it.

D1 is needed in the general case where the load may be at least somewhat inductive.  Consider the case of the load being a pure inductor.  If Q1 is suddenly switched off, the instantaneous inductor current will keep flowing somewhere.  Without D1 that somewhere is achieved by raising the collector voltage to the point where the transistor conducts despite it being switched off.  This requires a high voltage and can damage the transistor and other parts the load may be connected to.  D1 provides a safe path for the inductive kickback current.  D1 is not needed if driving a resistive load on the same board.  Adding D1 whenever going off-board is a good idea since you no longer control what might get connected, and long leads have their own inductance, even if the load is not inductive.

The maximum load current is the base current times the transistor gain.  In the example above, we decided that the minimum guaranteed base current is 3.9 mA.  If the transistor is guaranteed to have a gain of 50 at that current, for example, then the circuit is good for loads that draw up to 195 mA.

Another fairly simple way to switch a load from a digital signal is to use a low side N-channel FET that can be driven directly from logic-level signals:



The FET is voltage-controlled, unlike the NPN transistor above, which is current-controlled.  The FET gate looks like a capacitive load to the digital output.  You have to be careful if the digital output is specified to work with some maximum capacitance.  Most of the time, more capacitance on a digital output just slows the slew time.

In this simple circuit, the FET must be controllable from logic-level voltages.  Such FETs are often called logic level FETs.  For example, the IRLML2502 is specified for 80 m&Omega; maximum at 2.5 V gate drive.

The FET must be rated to withstand the power voltage when off.  FETs that work at logic-level gate voltages usually don't go to high D-S voltages.  The IRLML2502, for example, is only good to 20 V.  Above 30 V you will have problems finding a logic level FET, and different gate drive will have to be considered.

The maximum load current of course can't be more than the maximum current the FET is rated for.  However, power dissipation is usually the actual limiting factor.  For example, the IRLML2502 is rated for 800 mW at at 70 &deg;C ambient.  That comes out to 250 mA using the 80 m&Omega; figure from above.