# 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).

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.

*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

### 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.

Click to enlarge

## Testing

Components used in this example

*As an Amazon & Ebay Associate I earn from qualifying purchases.

## 5 Replies to “How to use the 2N2222 Transistor (NPN) (with examples)”

1. William Kuchta says:

This is a really excellent video, thank you for putting this on the internet. Some very clean math. This is very helpful to understand what it says on a spec sheet, thanks for making this.

2. Robert Bailey says:

You have an extensive explanation however I see no video to follow your circuit description.

3. Mike says:

This was a great tutorial for me, I’m a few months into learning electronics and I’m trying to recreate what you have done, to power a super bright IR LED from an esp32 dev board. However the maths has beaten me (I’m generally ok with basic maths, but not the principles for electronics.)

If you’re still around I’d love to get your opinion at my attempt to recreate this? I put all the details on an Arduino forum.

Many thanks.

4. www.racingclassifieds.Com.au says:

Having some clean house between the textual content and the
pictures can enable readers to simply digest the information.