Transistor as a Switch
A BC547 transistor works as a controlled switch: a tiny current into its base lights an LED. No code required.
Bill of materials
Everything you need to build it, with the reference you will see on the schematic.
| Qty | Part | Ref. |
|---|---|---|
| 1 | Pushbutton | S1 |
| 1 | 10 kΩ resistor (brown-black-orange) | R1 |
| 1 | 100 kΩ resistor (brown-black-yellow) | R3 |
| 1 | BC547 NPN transistor | Q1 |
| 1 | 470 Ω resistor (yellow-violet-brown) | R2 |
| 1 | red LED | D1 |
| 1 | 9 V battery with snap clip | BT1 |
| 1 | Breadboard (400 tie-points or more) | |
| 6 | Jumper wires |
Missing parts? The kits recommended by Impeca Tech include almost all of them. See the kits
Schematic & wiring
On the left, the circuit diagram; on the right, the same circuit built on a breadboard. Both connect exactly the same things.
Wire it step by step
-
Place the components
- Pushbutton S1 straddling the centre channel of the breadboard: two legs on top (3f and 5f) and two below (3e and 5e).
- 10 kΩ resistor R1 (bands: brown, black, orange, gold): one leg in 6f and the other in 9f (either way round).
- 100 kΩ resistor R3 (bands: brown, black, yellow, gold): one leg in 9h and the other in 4h (either way round).
- BC547 transistor Q1 with the flat face (the one with the text) towards you, left to right: collector (C) in 14f, base (B) in 15f, emitter (E) in 16f.
- 470 Ω resistor R2 (bands: yellow, violet, brown, gold): one leg in 10f and the other in 13f (either way round).
- red LED D1: the long leg (+, anode) in 13h and the short leg (−, cathode, flat side) in 14h.
-
Add the jumper wires
- Red wire: from 3j to the + (red) rail.
- Red wire: from 10j to the + (red) rail.
- Orange wire: from 3d to 6j.
- Turquoise wire: from 9j to 15j.
- Black wire: from 4j to the − (blue) rail.
- Black wire: from 16j to the − (blue) rail.
-
Connect the battery
- Connect the 9 V battery to its clip: the clip’s red lead to the + (red) rail and the black one to the − (blue) rail. Do this last, once everything else is in place.
-
Test the circuit
- With S1 released the LED should be off; press S1 and it lights, release it and it goes off. To check how it works, measure with the multimeter between the base and GND: about 0.7 V while you press.
How to read the holes: the letter is the row and the number is the column of the breadboard (for example 7f). The red (+) and blue (−) rails are the two long lines along the edge.
How does it work?
- 1You press S1
- 2A small current enters the base
- 3The transistor conducts between collector and emitter
- 4The LED lights up
The transistor has three legs: base (B), collector (C) and emitter (E). Pressing S1 lets R1 pass about 0.8 mA into the base, which is enough for the transistor to turn fully on and let the LED current (about 15 mA) flow from C to E. R3 holds the base at 0 V when you are not pressing, so the transistor does not switch on by itself from stray interference. A small current controls a larger one: the principle behind every digital circuit.
Testing & troubleshooting
What you should see
- Button released
- LED currentunder 1 µA
- Button pressed
- Base current≈ 0.82 mA
- LED (collector) current≈ 15 mA
- Collector-emitter voltage≈ 0.05 V
Approximate values, calculated with typical parts. With real parts they can vary by 10 % or more.
If something does not work
The LED is always on?
Check the orientation of the BC547: with the flat face towards you the legs are Collector, Base, Emitter from left to right. Also check the LED polarity.
The LED does not light when pressed?
Check that the button legs straddle the centre channel and that R1 (10 kΩ, brown-black-orange) reaches the base. If R3 (100 kΩ) is in R1’s place the base current is too small.
Want to automate this circuit with code?
Learn how to program sensors and custom schedules in our e-book “Arduino from Scratch”.