Labs / Digital · Intermediate · 30 min
Transistor switch
Drive an LED load with an NPN transistor.
Engineering instrumentation: This lab includes an instrument-style virtual test setup and parameter-driven waveform. For physical measurements, use the Practical Bench.
Parts
- NPN transistor BC547
- Base resistor 10k
- LED and 220 ohm
- ESP32
Steps
- Connect the ESP32 pin to the base through Rb.
- Put the LED and its resistor between 5 V and the collector.
- Connect the emitter to GND.
- Turn the pin ON and OFF.
Safety: check polarity and power off before changing the circuit.
ESP32 code (Arduino IDE)
const int B=23;
void setup(){ pinMode(B,OUTPUT); }
void loop(){ digitalWrite(B,HIGH); delay(1000);
digitalWrite(B,LOW); delay(1000); }Viva questions
Why is a base resistor needed?
It limits base current, otherwise the pin and transistor can be damaged.
What is beta?
The current gain Ic / Ib, typically 100 to 300.
Saturation?
The transistor is fully ON, Ic is set by the load, not by beta.