Description
Tutorial: How to Use the 2N2222 Transistor
The 2N2222 transistor is a fundamental component for those starting to explore the programming of electronic circuits. This NPN device can be used to amplify or regulate the flow of electrical current, making it ideal for both Arduino projects and more complex electronic schematics.
What you need
- Arduino Uno
- Resistor
- LED
Steps
- Check the polarity of the transistor: the middle pin (base) should be higher than the two outer pins (emitter and collector).
- Connect the emitter of the transistor to the cathode of the LED, while the anode of the LED goes to an output pin of the Arduino.
- Use a resistor between the base pin of the transistor and an output pin of the Arduino to limit the current.
- Connect the anode of the LED to the emitter of the transistor.
- Connect the collector pin of the transistor to the emitter pin of the LED, both to ground (GND).
- Write an Arduino sketch that turns an LED on and off by controlling the current through a transistor.
- Verify the circuit function using the serial monitor to display the state of the Arduino output.
- If necessary, adjust the resistor values based on the specifications of your LED and transistor.
Example code
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // accende l'LED collegata al pin 13 dell'Arduino tramite il transistor
delay(1000); // attesa di un secondo
digitalWrite(13, LOW); // spegne l'LED
delay(1000); // attesa di un secondo
}
Mini project
Build a bedside lamp controllable with Arduino. Connect the transistor to a relay and use this to turn a light bulb on or off.
Common mistakes
- Do not check the polarity of the transistor before connecting it to the circuit.
- Omit the resistor between the Arduino and the base of the transistor, causing damage to the Arduino.
- Use an LED without a protective resistor that limits the current.
- Do not check the datasheet to verify the values of the components.
Recommended accessories
- Variable resistors
- Relay (5V)
- Arduino Uno
- Basic prototyping kit
Frequently asked questions
Why use a transistor instead of connecting the LED directly?
A transistor allows managing higher currents than what the Arduino pin could handle, thus protecting the device.
What is the difference between an NPN and PNP transistor?
An NPN transistor can turn on a circuit when activated, while a PNP turns it off. The choice depends on the desired direction of current flow.
Can I use the 2N2222 with other microcontrollers?
Yes, the 2N2222 is compatible with most microcontrollers that provide an adequate voltage level.






Reviews
There are no reviews yet.