Transistors are commonly used for switching. They act just like a physical ON/OFF switch. Transistors are a separate subject altogether, hence the focus will be to stick to the basics, to the extent needed to start building prototypes with the Arduino.
A typical transistor has three legs, known as: Collector, Base, and Emitter. The most common types of transistors are classified as PNP and NPN transistors. If you hold the flat face of a transistor towards yourself, then for a PNP type transistor, the legs are arranged in the order--Collector, Base, and Emitter (from left to right); whereas for a NPN transistor, the legs are arranged as Emitter, Base, and Collector (from left to right).
A transistor is built in such a way ...