PN2222A transistor

Transistors are just about everywhere in electronics. They are used in digital switches, amplifiers, voltage regulators, and many other simple components that work together in complex digital circuits. Two types you're likely to use are the bipolar junction transistor (BJT) and the field effect transistor (FET).

Both types of transistor have three pins. The pins on the bipolar junction transistor are called the emitter, collector, and base. On the field effect transistor, the pins are called the source, drain, and gate.

In both cases, the basic principle is that voltage applied to one pin (the base/gate) determines whether current can flow across the two other pins. In this way, the transistor acts as a switch based on high and low voltages instead of physically flipping a switch or pressing a button.

Example: AND logic gate

Let's look at a circuit that uses transistors. This circuit will implement the logical AND operation using two buttons for input and one LED for output. The LED is off by default. If you press button 1 or button 2, the LED remains off. But if you press both button 1 and button 2, the LED will light up. Thus, the AND gate.