Transistor as a Switch: BC547 Explained for Beginners
Learn how a BC547 NPN transistor works as a switch: pinout, base resistor calculation with a worked example, and a flyback diode for relays.
On this page
An Arduino pin can give only about 20 mA, but a relay, a motor or a strip of LEDs often needs more. The answer is a transistor: a tiny electronic switch where a small current at one pin controls a bigger current through the other two. The BC547 is the most common small NPN transistor, and you will find it in every electronics shop in Nepal.
In this guide you will learn the BC547 pinout, how to calculate the base resistor with a worked example, and why a relay needs a flyback diode.
Safety note
Keep all experiments at 12 V DC or lower. Relay modules switch mains in some projects, but mains wiring is for a qualified electrician only, and this tutorial uses only low-voltage loads. Connect the power last, and check the transistor orientation before powering.
What you need
Scroll sideways to see all columns.
| Item | Qty | Notes |
|---|---|---|
| BC547 NPN transistor (B or C version is fine) | 1 | TO-92 package |
| Resistor 560 Ω (base resistor) | 1 | Green-blue-brown |
| Resistor 10 kΩ (pull-down) | 1 | Brown-black-orange |
| 5 V relay, e.g. a 5 V type with a coil current of about 70 mA | 1 | Coil about 70 mA |
| Diode 1N4007 | 1 | Flyback diode |
| LED + 330 Ω resistor | 1 | Shows relay output |
| Arduino Uno (or 5 V supply plus a push button) | 1 | Signal source |
| Breadboard, jumper wires | 1 set | |
| Digital multimeter | 1 |
BC547 pinout: be careful here
Hold the BC547 with the flat side facing you and the legs pointing down. From left to right the legs are:
Collector (C) – Base (B) – Emitter (E)
This is the order in the standard datasheet for the BC547, BC548 and also BC557 (the PNP version). Many websites say "EBC", but that order belongs to other transistors such as the 2N3904 and the plastic 2N2222. Mixing them up is the most common beginner mistake. If you are unsure, check the datasheet of the exact part you bought, or use the hFE socket on your multimeter, where a correct insertion gives a reasonable gain reading.
Scroll sideways to see all columns.
| Pin (flat side to you, left → right) | Name | Job |
|---|---|---|
| 1 | Collector | Load current flows in here |
| 2 | Base | Small control current goes in here |
| 3 | Emitter | Current leaves here, to GND |
Key limits for the BC547: maximum collector current 100 mA, maximum collector-emitter voltage 45 V, and about 500 mW power. Those limits are why a relay coil of 70 mA is already close to its comfortable range.
How an NPN transistor switches
For an NPN transistor used as a switch, the load connects between the supply (+) and the collector, and the emitter goes to GND.
- Base at 0 V: no base current, the transistor is OFF, and no current flows through the load.
- Base driven above about 0.7 V with enough current: the transistor is ON (saturated). The collector-emitter voltage drops to about 0.1-0.3 V and the load current flows.
The base-emitter junction behaves like a diode, which is why the base sits at about 0.65-0.7 V when the transistor is on. The base needs a resistor in series, or the junction would draw too much current and burn the transistor or the pin driving it.
Calculating the base resistor (worked example)
Goal: switch a relay with a 70 mA coil from a 5 V Arduino pin.
Step 1: collector current. I_C = 70 mA.
Step 2: base current. To make sure the transistor is fully ON, do not rely on the full gain (hFE). A safe rule is "forced beta of 10": I_B = I_C / 10 = 70 mA / 10 = 7 mA.
Step 3: base resistor. R_B = (V_signal − V_BE) / I_B = (5 − 0.7) / 0.007 = 4.3 / 0.007 ≈ 614 Ω.
Step 4: pick a standard value. The nearest common values are 560 Ω and 680 Ω. Choose the lower one so there is slightly more base current: 560 Ω gives I_B = 4.3 / 560 ≈ 7.7 mA. That is comfortably under the Arduino's 20 mA pin limit.
Check the power in the transistor. With V_CE(sat) of about 0.2 V: P = 0.2 V × 0.07 A = 0.014 W = 14 mW, which is tiny, so no heat sink is needed.
Second example: 3.3 V signal driving a 12 V relay
A 12 V relay with a 40 mA coil, signal from a 3.3 V microcontroller. With forced beta 10, I_B = 4 mA. R_B = (3.3 − 0.7) / 0.004 = 650 Ω. Pick 560 Ω (I_B ≈ 4.6 mA). A 560 Ω resistor also works for the earlier 5 V example, which makes it a handy value to keep in your kit.
Quick reference
Scroll sideways to see all columns.
| Load current | I_B (forced beta 10) | R_B at 5 V signal | Standard value |
|---|---|---|---|
| 20 mA (LED strip piece) | 2 mA | 2.15 kΩ | 2.0 kΩ |
| 50 mA | 5 mA | 860 Ω | 820 Ω |
| 70 mA (5 V relay) | 7 mA | 614 Ω | 560 Ω |
For loads close to 100 mA, use a stronger transistor such as the BC337 or 2N2222.
The flyback diode (do not skip it for relays)
A relay coil is an inductor. When the transistor switches OFF, the coil's magnetic field collapses and produces a voltage spike in the opposite direction, which can reach tens of volts. That can destroy the transistor, and can even reset an Arduino.
The fix is one diode across the coil:
- Cathode (stripe) to the + supply side of the coil.
- Anode to the collector side of the coil.
In normal operation the diode is reversed (blocking). When the spike comes, it conducts and lets the coil current circulate harmlessly. A 1N4007 both work for small relays. Wired backwards, the diode shorts your supply, so check the stripe direction.
Wiring table
Scroll sideways to see all columns.
| From | To |
|---|---|
| Arduino D7 (signal) | 560 Ω resistor → BC547 base |
| BC547 base | 10 kΩ → GND (pull-down, keeps it off when the pin floats) |
| BC547 emitter | GND (shared with Arduino GND) |
| BC547 collector | Relay coil terminal A |
| Relay coil terminal B | +5 V |
| 1N4007 cathode (stripe) | +5 V (coil terminal B) |
| 1N4007 anode | BC547 collector (coil terminal A) |
| Relay COM | Demo load supply +5 V |
| Relay NO | 330 Ω → LED anode |
| LED cathode | Demo load supply GND |
Signal path in one line:
D7 → 560 Ω → base ; +5 V → relay coil → collector → emitter → GND ; flyback diode across the coil
Step-by-step build
- Insert the BC547, flat face towards you, and note C, B, E from left to right.
- Connect the emitter to GND.
- Connect the base resistor (560 Ω) from the signal source to the base, and the 10 kΩ pull-down from base to GND.
- Connect the relay coil between +5 V and the collector. Do not forget the diode across the coil.
- Power up. Drive the signal HIGH (set D7 to OUTPUT with
pinMode(7, OUTPUT), then usedigitalWrite(7, HIGH), or touch the signal wire to +5 V through the resistor). The relay should click. - Drive D7 LOW or disconnect the push-button signal. The relay clicks off.
Testing with a multimeter
- Diode test on the transistor (power off): diode mode, red probe on base, black on emitter: about 0.6-0.7 V. Red on base, black on collector: about 0.6-0.7 V. Reversed: OL. Collector to emitter either way: OL. A reading near 0 between any two pins means a shorted transistor.
- V_BE when ON: red on base, black on GND, about 0.65-0.75 V.
- V_CE when ON: collector to GND is about 0.1-0.3 V. A reading of 2 V or more means the base is not driven hard enough: lower R_B.
- Coil voltage when ON: about 4.7-4.9 V across the coil.
- Base current: measure the voltage across R_B and divide by R_B. For example 4.3 V across 560 Ω gives 7.7 mA.
Troubleshooting
Scroll sideways to see all columns.
| Symptom | Likely cause | Fix |
|---|---|---|
| Relay never clicks | Transistor pins swapped (EBC vs CBE) | Re-check with the flat side facing you: C, B, E |
| Relay chatters or is weak | Base resistor too large, so transistor is not saturated | Use 560 Ω or lower |
| Relay stays on | Collector-emitter shorted (damaged), or base floating | Replace the transistor; add the 10 kΩ pull-down |
| Transistor gets hot | Load current over 100 mA | Use a larger transistor |
| Arduino resets when relay turns off | No flyback diode, or diode reversed | Fit the 1N4007, stripe to +5 V |
| Works from a battery, not from Arduino | Grounds not shared | Join all GND connections |
FAQ
Can I use a BC548 or 2N2222 instead?
A BC548 is almost identical. A 2N2222 (metal can or plastic) handles more current (up to 600 mA), but check its pinout, which differs.
What is the difference between the BC547 and BC557?
The BC557 is the PNP partner. It switches on when the base is pulled LOW compared with the emitter, and the load goes on the collector side to GND.