# Transistor how to turn lamp on/off

I am trying to design a very simple schematic and trying to understand how the transistor works as switch.

• Transistor: Datasheet
• Description: NPN - Pre-Biased 100mA 50V 100mW USM(SC-70-3) Transistors (NPN/PNP) RoHS

Assuming I have the + of a lamp connected to P and the - of the lamp to N, if IO18(connected to a microcontroller) is "low" the light will be off.

If IO18 is set to high, will the lamp turn ON with the way I designed the schematic?

Edit: Why does this transistor have embedded resistors?

Your circuit will function correctly and do what you expect.

The transistor you have is intended to reduce the parts count and save space on your PCB - you only have to place one part instead of three.

You need a resistor in series with the base of the transistor to limit the current through the base. Too much current could damage the transistor (if your microprocessor can deliver enough current.) Alternatively, it prevents damage to the microprocessor by limiting the current drawn from the processor pin.

The resistor from the base to ground is often left out. It takes care of the case where there is no signal on the base. It pulls the base to ground to make sure the transistor stays "open" (and the lamp off.) The outputs of many processors is "high impedance" at power on - the output is neither high nor low, but rather "floating." In that condition, the base of the transistor could pick up enough stray current to turn on the lamp (or do other, worse things) when it shouldn't. The resistor to ground prevents those undefined events from happening.

Yes, that's correct. If you set your IO18 to a HIGH it will turn the transistor ON and current will flow through your lamp.

(this assume that your two resistors that are shown without values are appropriately chosen.)

• So VCC12V is always connected to the + of the lamp while ground is no and thats why lamp is off. When IO18 is high, lamp's - will be connected to ground and its going to turn on. Is that correct? I have edited also the post.
– Kris
Feb 1, 2021 at 18:00
• The lamp must also be rated at or below 100mA as that is the maximum current the transistor can switch. Feb 1, 2021 at 18:03
• @justme thanks also Why this transistor has embedded resistors? Where do they help?
– Kris
Feb 1, 2021 at 18:09
• @Kris "Why this transistor has embedded resistors?" Simply to reduce component count. Feb 1, 2021 at 19:02

Basically, this circuit (transistor switch) needs only one resistor connected between the input voltage source and the base. The role of this base resistor is to expand the input voltage range of the transistor that is several hundred millivolts.

Why is there a need of the second input resistor connected between the base and emitter? It is necessary if the input voltage source is of the "open collector" type. Then zero input voltage means open input circuit and the base would be "floating". This is undesirable because all sorts of leaks and induced voltages can turn on the transistor. So, the role of the second resistor is to shunt the base-emitter junction thus zeroing the undesired parasitic voltages.

The collector resistor R34 would be necessary if an LED instead a lamp would connected in the collector. Diode elements, including LED, are voltage stabilizers that keep up a constant voltage drop across them (in the case of LED, it is about 2-3 V). So, the transistor will try to keep 12 V across the LED... while the LED will try to keep 2 V. As a result of this "conflict" between two voltage-type elements in parallel, the current will enormously increase... and some of them will be damaged. R34 prevents this by limiting the current.

In the future, follow this simple rule: There must be at least one resistor in a circuit of series-connected voltage sources and diodes.

• Comments are not for extended discussion; this conversation has been moved to chat. Feb 3, 2021 at 16:27