I wanted to control an LED using a transistor (my first attempt at using a transistor). I connected a transistor (TL188) to pin 13 of an Arduino Uno accidentally and noticed something.

Enter image description here (The resistor I used was 150 ohms, and I forgot to change the resistor value in the diagram.)

The program on the Arduino Uno was the basic Blink sketch. As per the program, the LED on the Arduino Uno was supposed to turn on for 1000 ms and turn off for 1000 ms. But when I connected the LED like the diagram below

For the first 1000 ms delay:

  • LED on pin 13 stayed on
  • LED connected using the transistor stayed off

For the next 1000 ms delay:

  • LED on pin 13 stayed partially on (it was dim)
  • LED with the transistor was on

I know that the connection that I made is completely wrong. Can someone explain me how and also why the LED on the Arduino Uno was dim?

  • Your transistor is a PNP transistor. They are slightly harder to work with than NPN transistors. I would suggest starting with an NPN transistor as a low side switch first before stepping up to PNP transistors.
    – Majenko
    Commented Jan 11, 2016 at 14:45
  • Okay,. But the reason i used a PNP was, I have a bunch of 7segment LED(common anode type). so before connecting a segment i wanted to just try connecting an LED.
    – arvindh
    Commented Jan 11, 2016 at 14:57
  • @Rob It's not too bad if all your voltages are the same - it's when you start trying to switch higher voltages with a lower voltage signal that you get difficulty - you can't get the base voltage up to the level of the emitter to get it to turn off. You then need extra drive circuitry or other trickery.
    – Majenko
    Commented Jan 11, 2016 at 15:25
  • Did you connect ground correctly? Looks like an external power source (battery) but not ground is not common. Commented Jan 11, 2016 at 15:41
  • > If you provide complete details of your setup So, giving specifics as I think it would help understand the maths, if you have say a 10 3.4v\25ma LEDs in 5 sets of 2 LEDs with a 100ohm resistor on each pair connected to a 9v supply along with an Arduino Nano (5v\40ma PWM output pins) with say a 2N3904 transistor (NPN, 200ma max, ~0.7v drop, 100-300hfe I think) how do you calculate "a resistor in the range 1K to 2K should do"?
    – HeMan
    Commented Jun 11, 2019 at 8:27

2 Answers 2


You should have a resistor of a few hundred ohms on the base connection of the transistor - that is, between base and pin 13.

A PNP transistor is somewhat harder to get to grips with than an NPN transistor. Much of it does things backwards.

The operation you see seems to be completely correct when you understand how a PNP works.

With and NPN transistor a high voltage on the base turns it on and a low voltage turns it off. The opposite is true with a PNP transistor.

When you have a voltage close to or above the voltage at the emitter the transistor will be off. That means, providing a HIGH to the base will turn it off. A voltage on the base that is below the emitter voltage minus the threshold voltage of around 0.7V will turn the transistor on. That means providing a LOW to the base will turn it on.

So that means that when the on-board LED is on the transistor is off, and so the LED on the transistor will be off. When the LED on the board is off the transistor will be on, so the LED on the transistor will be on.

"But", you say, "the on-board LED doesn't turn off". That is correct. It just gets dimmer. That is, again, because of how the PNP transistor works. Current (seen from the conventional sense - i.e., flowing from + to -) enters the emitter and is then split between the collector and base. The amount of current allowed to flow out of the base defines how much is allowed to flow out of the collector (in an NPN it's current into the base and collector that combine to flow out of the emitter, and the amount that is allowed to flow into the base defines how much is allowed to flow into the collector). So there will be some current flowing out of the base - which makes its way to ground both through the microcontroller's IO pin and also through the LED on board, making it glow slightly*.

*That is a little crudely put, but kind of illustrates what is going on.

  • In what way are PNP transistors "harder to work with"? They do things "backwards" compared to a NPN but NPN works "backwards" compared to PNP.
    – Rob
    Commented Jan 11, 2016 at 15:25
  • @Rob Everything is the opposite of its opposite. Of course an NPN does the opposite to a PNP if a PNP does the opposite of an NPN.
    – Majenko
    Commented Jan 11, 2016 at 15:26
  • Thanks for the explanation. So if some amount of current is flowing back through the pin and into the microcontroller, then the controller will get damaged right.? By adding a resistor as you suggested will also allow some amount of current to pass through. Am i correct ? so can a PNP be never connected to a controller's pin(even using a resistor on the base) directly ?
    – arvindh
    Commented Jan 11, 2016 at 15:26
  • My point is, PNP works differently than an NPN but it is not more difficult. Just different.
    – Rob
    Commented Jan 11, 2016 at 15:27
  • Some current is safe. Up to the limit of what the IO pin can handle (40mA absolute maximum, 25mA sustained recommended maximum). The resistor is there to limit that current to a safe level so it doesn't exceed those limits.
    – Majenko
    Commented Jan 11, 2016 at 15:27

It really doesn't matter if you use a PNP or NPN transistor, they are just mirrors of one another. If you have some common anode displays then just start directly with the PNP's.

The flaw I see in your circuit is that you should always use 2 resistors to drive a LED (See schematic). R2 (as you already have) will limit the current to the LED; 220 Ohm you as illustrated is fine.

R1 is needed between the I/O pin and your transistor. This will limit the current through the I/O pin. For what you are attempting a resistor in the range 1K to 2K should do, even if you're switching a few LED's in parallel. If you provide complete details of your setup we can always refine the calculations. One can then take into account the total currents from your displays, the amplification factor of the transistor (hfe) etc. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.