# NPN Transistor (S8050)

## What is Transistor
Transistor is a current-controlled amplifying device that can control large current with small current.
## Pin Description
S8050 NPN transistor has 3 pins:

- **E (Emitter)**: Usually connected to GND
- **B (Base)**: Control pin, input small current
- **C (Collector)**: Output pin, output large current
## Working Principle
- **Base Current (IB)**: Controls transistor conduction
- **Collector Current (IC)**: Amplified output current
- **Current Gain (β)**: IC = β × IB (S8050 about 100-300 times)
## Operating Modes
- **Cutoff Region**: Base current is 0, transistor does not conduct
- **Active Region**: Base current controls collector current, for signal amplification
- **Saturation Region**: Base current is large enough, transistor fully conducts, used as switch
## Connection Method
### Transistor Switch Circuit (Direct Visual Effect)

### Connection Instructions (Switch Application)
According to the diagram above, connection order is:
```
VCC (5V) → Current Limiting Resistor (1KΩ) → Base (B)
VCC (5V) → LED → 220Ω Resistor → Collector (C)
Emitter (E) → GND
```
**Working Principle**:
- **Base Has Current**: Transistor conducts, resistance between collector and emitter is very small, LED lights up
- **Base Has No Current**: Transistor blocks, resistance between collector and emitter is very large, LED turns off
- Can use small current (base) to control large current (collector), achieving switch function
**Effect**: By controlling base current, can control LED on/off, visually see transistor's switching effect
### Amplification Application
Used to amplify weak signals, such as sensor signals. Requires bias circuit configuration, not detailed here.
## Arduino Example Code
### Basic Example: Transistor Controls LED
```cpp
const int basePin = 9; // Pin connected to base
void setup() {
pinMode(basePin, OUTPUT);
}
void loop() {
digitalWrite(basePin, HIGH); // Transistor conducts, LED lights up
delay(1000);
digitalWrite(basePin, LOW); // Transistor blocks, LED turns off
delay(1000);
}
```
### Connection Method
- **Arduino Pin 9** → 1KΩ Resistor → **Base (B)**
- **Collector (C)** → LED → 220Ω Resistor → **VCC (5V)**
- **Emitter (E)** → **GND**
### Code Explanation
- Transistor used as switch, base current controls collector current
- Base must be connected in series with current limiting resistor (1KΩ) to prevent damage
- Collector can connect to LED, relay, and other loads
## Common Questions and Answers
### Q1: Transistor Not Working?
- Check if base is connected in series with current limiting resistor
- Check if pin connections are correct (E, B, C)
- Check if collector load is connected
- Confirm it's NPN transistor (not PNP)
### Q2: Why Base Current Limiting Resistor is Needed?
- Excessive base current may damage transistor
- Usually use 1KΩ - 10KΩ current limiting resistor
- Resistor value too small will cause excessive base current
### Q3: What's the Difference Between Transistor and MOSFET?
- **Transistor**: Current controlled, needs base current
- **MOSFET**: Voltage controlled, almost no control current needed
- MOSFET more suitable for high current applications
## Safety Precautions
⚠️ **Important Notes**:
- Base must be connected in series with current limiting resistor to prevent damage
- NPN Transistor: Emitter to GND, Collector to positive supply
- Cannot exceed maximum collector current (S8050 is 0.5A)
- Pay attention to heat dissipation, high current applications need heat sink
## Practical Applications
Transistors are commonly used for switch control, signal amplification, current driving, etc. In Arduino projects, commonly used to control LEDs, relays, small motors, and other loads.