starter kit/Switching/11. A transistor as a switch
Switching · 11 of 16

A transistor as a switch

A transistor lets a small current switch a larger one. With one S8050, a base resistor and the button from the last circuit, about 0.8 mA through the base lights an LED at about 12 mA, and the transistor has only a tenth of a volt across it.

You need the button circuit working, one S8050 transistor, one 4.7 kΩ and one 10 kΩ resistor, a 220 Ω resistor and a red LED. The button, the LED and the 220 Ω are the ones you have already used.

Why a transistor

In the last two circuits the button carried the whole current that lit the LED. That is fine at 13 mA, and fine for a button. It is not fine when the thing being switched is a motor, or when what presses the button is the output pin of a board, which can only supply about 20 mA. A transistor is the part that lets a small current decide whether a larger one flows.

Find the legs

The S8050 is a small black plastic body with a flat face and three legs. With the flat face towards you and the legs pointing down, the order in the onsemi SS8050 datasheet is emitter, base, collector from left to right. Makers have printed other orders on other parts in the same case, so check yours with the meter before you plug it in.

Which leg is which
Look at
Leg 1
emitter
Leg 2
base
Leg 3
collector
Flat face towards you, legs down: emitter, base, collector, left to right. That is the order in onsemi's SS8050 datasheet, and the usual one for an S8050. Other makers, and other transistors in the same black case, can differ, so confirm it with the meter before you wire it.

In diode mode, put the red lead on a leg and the black lead on another. The base is the one leg that reads about 0.65 V to both of the others with the red lead on it. Nothing reads between the other two legs, and nothing reads with the leads the other way round. That finds the base for certain. Telling the emitter from the collector with a meter alone is not reliable, so rely on the datasheet order, and on the circuit working.

Three legs, two jobs

The base is the control. The collector and emitter are the path: current goes in at the collector, out at the emitter, and flows only if the base is fed. The base and emitter are a diode, so a base needs a resistor in series, exactly as an LED does, or it takes more current than it can stand.

Here the button feeds the base through a 4.7 kΩ resistor. A 10 kΩ from the base to the minus rail makes sure the base sits at 0 V when the button is open, for the same reason the last article gave: a base connected to nothing floats, and a floating base turns the transistor on and off at random.

Build it

The LED and its 220 Ω now sit on the collector side, from the rail to the transistor, and the emitter goes straight to the minus rail.

Circuit three, on the breadboard
The button
Into the base
0 mA
Through the LED
0 mA
Collector to emitter
4.8 V
Released: nothing reaches the base resistor, the pull-down holds the base at 0 V, and the transistor is off. The LED sits in a loop with a gap at the transistor, so no current flows and the voltage across the transistor is the whole rail.

The button is wired from opposite corners as before. The base resistor runs from the button's output strip to the base's strip. The LED's short leg goes to the collector's strip, and the 220 Ω runs from the LED's long leg to the plus rail.

Why a few kilohms

The current into the base is set by the base resistor: (4.8 V less the 0.65 V the base junction takes) over 4.7 kΩ, less a little that the pull-down steals, is about 0.82 mA. The transistor's gain, hFE, is the factor between base current and collector current, and on the S8050 the datasheet gives 85 to 300, measured at 100 mA. So the gain would ask for 70 to 245 mA through the LED.

The LED branch cannot carry that. Its own 220 Ω limits it to about 12 mA. When the gain asks for more than the load can take, the transistor stops being an amplifier and becomes a closed switch: it is saturated, and the load sets the current. Only 0.82 mA goes in and 12 mA comes out, about fifteen times as much. The voltage left across the transistor is about 0.1 V.

Base current in, LED current out
Base resistor
Base pull-down
This transistor's gain (hFE)150
Base current
818 µA
LED current
12 mA
Gain in use
15 (forced)
Saturated: the gain would ask for 123 mA, far more than the LED branch can take, so the LED's own resistor sets the current at 12 mA and the transistor is wide open, with about 0.1 V across it. Even the weakest S8050 (gain 85) would do the same: the base current is 10 times what the gain 150 needs. The ratio of LED current to base current is 15 to 1, against the rule of thumb of 10 to 1 that a switch is designed for.

Try the 1 MΩ base resistor in the plot, with the pull-down and without it. With it, the pull-down and the 1 MΩ form a divider that holds the base far below 0.65 V, and nothing turns on. Without it, the transistor works as an amplifier, and the LED's brightness follows the gain, which is different for every transistor. A switch should never depend on that.

In order

Press to light, in order
Base current
0 mA
LED current
0 mA
Collector to emitter
4.8 V
The button is released. The pull-down holds the base at 0 V, the transistor is off, and the LED, in a loop with a gap at the transistor, is dark.

The button carries only the base current, a little under 1 mA. It is the transistor that carries the LED's current. This is the whole idea: a small current decides, and a large one obeys.

Measure

Set the meter to DC volts and press the button.

  • Base to emitter: about 0.65 V, between 0.6 and 0.7. This is the junction drop, and it barely moves however hard you drive the base.
  • Collector to emitter, pressed: about 0.1 V. Anything under 0.3 V is a switch that is closed. A volt or more means it is not saturated.
  • Collector to emitter, released: about the rail, 4.8 V, because no current flows and the transistor takes all the voltage.
  • Across the 220 Ω, pressed: about 2.7 V, which is the rail less the LED's 2 V and the transistor's 0.1 V. Divide by 220 Ω for about 12 mA.
  • Across the 4.7 kΩ, pressed: about 4.1 V. Divide by 4.7 kΩ and the base current is a little under 0.9 mA, of which about 0.065 mA goes down the pull-down and the rest into the base.

Where the limit is

The S8050 is rated for about 20 to 25 V between collector and emitter, and for hundreds of milliamps through them. Makers rate it differently: onsemi's datasheet says 25 V and 1.5 A, others say 20 V and 500 to 800 mA, and the kit's maker is not known, so assume the lowest of each. A single LED at 12 mA is a long way inside it. The kit also has a second kind of switch, the 2N7000, a MOSFET, and the next experiment in this handbook is about it.

When it does not work

The LED never lights when I press the button.

Press and measure from the base to the minus rail: it should read about 0.65 V. If it reads 0 V, the button or the base resistor is not connected. If it reads 0.65 V but the LED is dark, the collector side is wrong: the LED backwards, a missing 220 Ω, or the transistor's legs in the wrong order. Check the legs with the meter's diode mode first.

The LED is on with the button released.

The base is floating or being fed. The 10 kΩ pull-down must run from the base's strip to the minus rail. Check it is there and that its leg is in the right strip. Measure the base to the minus rail with the button released: it must read 0.00 V.

The LED lights but it is dim, and the transistor is warm.

The collector and emitter are probably swapped. A transistor works that way round, but with a gain that is a tenth or less of normal, so the base current cannot saturate it. Measure across it with the button pressed: with legs the right way round it reads about 0.1 V, and with them reversed it reads one volt or more.

The transistor gets hot to the touch.

It should not. At about 12 mA it dissipates a few milliwatts. Unplug it. The usual cause is a missing base resistor, which lets the base take far more current than it should, or a collector wired straight to the rail without the 220 Ω. Replace the transistor if it was hot: it may be damaged.

Can I use a 1 MΩ resistor as the base resistor?

With the 10 kΩ pull-down fitted, no: the pair holds the base at about 0.05 V and the transistor never turns on. Without the pull-down it works but dimly, and how dim depends on the gain of the particular transistor, which varies from about 85 to 300. A switch should not depend on that.

Where this goes next

The kit has a second kind of switch, the 2N7000. It is switched by a voltage on its gate and takes no current to hold it on.

Switch with a MOSFET →

Edit this page — content/books/estkit/a-transistor-as-a-switch.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Electronics Starter Kit, Breadboard, Power Module and Components

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum →