Transistors are a hands-down most significant electronic component in use today and the backbone of the digital revolution. They can be used in two basic ways—as an amplifier or as a digital switch. Our focus is going to be on digital switching, and we will be using a transistor type known as a Metal-Oxide-Semiconductor-Field-Effect Transistor (MOSFET), specifically, an N-Channel Enhancement Mode MOSFET—yes, it's a mouthful!
Don't get too caught up on the long technical name or the many forms of transistors that exist. The simple take-home here is that an N-Channel Enhancement Mode MOSFET works well as a digital switch that we can control using our Raspberry Pi, or as we will see later, from another source such as an optocoupler.
FETs are voltage-controlled transistors. Another type of transistor known as a Bipolar Junction Transistor (BJT) is a current-controlled transistor. BJTs are perfectly fine to use with a Raspberry...