Relay or small-motor driver
A logic pin plus a base resistor and a flyback diode lets a 2N2222 turn a 5 V relay or a small DC motor on and off. This is the canonical first transistor-as-switch circuit.
A general-purpose NPN bipolar transistor rated to 40 V and 600 mA, used to switch small loads or amplify low-power signals.

The 2N2222 is one of the most widely used NPN bipolar junction transistors. It works as an electronically controlled switch or amplifier: a small current into the base controls a much larger current flowing from collector to emitter. ON Semiconductor's common TO-92 version (P2N2222A) is rated for a 40 V collector-emitter voltage (VCEO) and up to 600 mA of continuous collector current.
Used as a switch, a logic-level signal fed through a base resistor drives the transistor into saturation so it can sink loads such as LEDs, small relays, and buzzers that a microcontroller pin cannot drive directly. Its DC current gain (hFE) runs roughly 100 to 300 at 150 mA, so a few milliamps of base current can control hundreds of milliamps at the collector.
Used as an amplifier, its 300 MHz transition frequency and low noise suit audio and low-RF stages. It is a small-signal part, with total dissipation around 625 mW at room temperature, so it is not intended for high-power or high-voltage loads.
| Pin | Function | Type |
|---|---|---|
E Emitter | Passive | Passive |
B Base | Analog | Digital input |
C Collector | Passive | Passive |
Verified from the Tinkered component library.
Connecting a microcontroller pin straight to the base lets excessive base current flow, which can damage the pin and push the transistor past its base ratings. Always include a series resistor (about 1 kOhm for 5 V logic).
The P2N2222A in TO-92 is Emitter-Base-Collector from the flat face, but the metal-can 2N2222 and other TO-92 parts like the BC547 use different orderings. Swapping collector and emitter stops it from switching, so check the datasheet.
It handles at most 600 mA and 40 V with around 625 mW of dissipation. Larger motors, high-current LED strips, or higher-voltage loads need a MOSFET or a dedicated power transistor instead.
Relying on the full current gain leaves the transistor only partly on, dropping a volt or more and heating up. Provide enough base current (a forced gain of roughly 10 to 20) so VCE(sat) stays low.
Relays, motors, and solenoids produce a reverse voltage spike at turn-off that can exceed the 40 V rating and destroy the transistor. Add a diode (such as a 1N4148 or 1N4007) across the inductive load.
A logic pin plus a base resistor and a flyback diode lets a 2N2222 turn a 5 V relay or a small DC motor on and off. This is the canonical first transistor-as-switch circuit.
A pair of 2N2222s with RC timing forms the classic astable multivibrator that flashes two LEDs alternately, a staple of introductory electronics courses.
Drop the 2N2222 Transistor into a circuit, write firmware, and simulate it in your browser, then deploy to real hardware. All in one editable Tinkered project.