Electronic – Transistor how to turn lamp on/off

npnpcbpcb-designtransistors

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?

enter image description here

Best Answer

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.