How to use the 2N2222 Transistor (NPN) (with examples)

Learn how to use the 2N2222 NPN transistor as a switch. In this post we’ll go over how to use the 2N2222 transistor to switch a bright LED Flash on and off. We will first switch the 2N2222 using a push button, and then will transition to test with an Arduino.

The 2N2222 is an NPN bipolar junction transistor (BJT). BJTs can be used to amplify analog signals, but they can be used as switches as well. Here we’ll show how to use as a switch.

The example to show this will be based on lighting a bright LED that will need a voltage and current larger than what an Arduino UNO IO pin can supply. Transistors operating as switches work by allowing a large current to flow through the collector when a small current flows through the base. In this example the LED operates between 9V – 14.8V at a current of 15mA, which is above the voltage and current of the Arduino UNO (see below).

2N2222 transistor symbol with terminals labeled.

LED Specs:
Voltage: 9V – 14.8V
Current when lit: 15mA

Arduino UNO Specs:
I/O Pins Voltage: 5V
Current per I/O Pin: 20mA

2N2222 Standalone application

Before jumping to wiring the transistor to an Arduino, let’s try it on a standalone application where we activate the transistor with a push button. The circuit and beard board diagram below show how we’ll setup our circuit.

In this example, the current ib represents the current that will be pulled from the Arduino UNO, while ic will be the current pulled from a separate power source. For this specific example, a 4.7kohm is being recommended and we’ll use a standard 12V voltage source to power the LED. Before doing some math to show why we are using that resistor, let’s check some specific specs of the 2N2222 transistor.

Breadboard diagram and circuit for 2N2222.

Click to enlarge

*Note that the LED flash used in this example is a ready-to-use component with a built-in resistor, which is why a separate resistor is not needed.

2N2222 Specs

Minimum current gain = 35
*The gain factor (Beta) is factor by which ib will be amplified.
*Note that Beta = ic/ib.

Min Saturation voltage VBE = 0.6V

Max Saturation voltage VCE = 1.0V

2N2222 specs.

Now let’s do some math

Let’s first assess the voltage drop from 12V to GND, and determine the minimum LED voltage we should expect based on the maximum expected voltage between the collector and the emitter (VCE ).

After solving for VLED_Min, we saw that the result was within the bounds of the LED operating voltage (9V – 14.8V), so we are good. Now, let’s assess the voltage drop from 5V to GND, and determine the value of the current ib.

We can see that the current ib is less than the maximum that the Arduino I/O pins can support, which is good. Now, let’s confirm the minimum current that we will be able to flow through the resistor based on the minimum current gain (remember this was 35 from the transistor specs).

The value above is higher than the current stated in the LED specs (15mA), this means that even at the lowest transistor current gain, we can still pull the required current to light up the LED.

2N2222 Testing

Now, let’s actually test this and setup a multimeter to compare the calculated values to actual values.

Base Current
Measured value: 0.91mA
Expected value: 0.94mA
*Close enough

Collector Current
I actually measured the emitter current, but iC = iE – iB. So iC = 17.61mA. The expected value was 15mA per the LED specs. The result is still acceptable.

Integrating the 2N2222 to the Arduino UNO

2N2222 breadboard diagram with Arduino.

Click to enlarge

Arduino Code


Testing the 2N2222 with Arduino UNO and an LED flash.

Components used in this example

Where to buy [Amazon Affiliate]:
*As an Amazon Associate I earn from qualifying purchases.
Arduino UNO:
Hilitchi Transistors Assortment Kit:
Electronic Component Kit:
Amprobe AM-510 Multimeter:
Amprobe TL35B Test Leads with Alligator Clips:
Breadboard (Elenco 9440):

Leave a Reply

Your email address will not be published. Required fields are marked *