Here’s how to use a TIP120 transistor to control higher voltage or higher current loads. This circuit will also work for an IRF520 MOSFET. The load could be a motor, or an ultrabright LED, or 50 LEDs you want to switch on with one pin, or anything higher voltage DC.
Maximum 60V, 5A (8A if pulsed). Datasheet: http://www.fairchildsemi.com/ds/TI/TIP120.pdf.
Note that there are many components that look like this. Its package, or form, is called TO-220. Many components are in TO-220 packages. Make sure you read the part number and it says TIP120. There are also other variants of transistors that also work the same basic way.
A 1k-2k resistor is used between an Arduino output pin and the base pin to protect the transistor, but can be calculated more exactly if efficiency or precision is needed (read “connecting a transistor to the output of an IC” half-way down this page). In practice, with a TIP120 you can omit the resistor with an Arduino since it can only supply 40mA per pin – but it’s better to develop good practice.
A protection diode is only necessary for inductive loads like motors or relay coils. It protects the Arduino from “flyback voltage.” Standard 1N4001 diodes are fine for most applications.
Diode polarity: power can flow in the direction of the arrow, but is blocked in the other direction
ITP Transistor Tutorial: itp.nyu.edu/physcomp/Tutorials/HighCurrentLoads
Transistors and Arduinos workshop video: