user6565: 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.

(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?

user16218: 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. 

user4143: 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.

6565: <p>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.</p>

<p><a href="https://i.stack.imgur.com/E2VZV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E2VZV.png" alt="Enter image description here"></a>
<em>(The resistor I used was 150&nbsp;ohms, and I forgot to change the resistor value in the diagram.)</em></p>

<p>The program on the Arduino Uno was the basic <code>Blink</code> sketch. As per the program, the LED on the Arduino Uno was supposed to turn on for 1000&nbsp;ms and turn off for 1000&nbsp;ms. But when I connected the LED like the diagram below</p>

<p><strong>For the first 1000 ms delay:</strong></p>

<ul>
<li>LED on pin 13 stayed <strong>on</strong></li>
<li>LED connected using the transistor stayed <strong>off</strong></li>
</ul>

<p><strong>For the next 1000 ms delay:</strong></p>

<ul>
<li>LED on pin 13 stayed <strong>partially on (it was dim)</strong></li>
<li>LED with the transistor was <strong>on</strong></li>
</ul>

<p>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?</p>
 16218: <p>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.</p>

<p>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.</p>

<p>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. <a href="https://i.stack.imgur.com/dGZvJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dGZvJ.png" alt="enter image description here"></a></p>
 4143: <p>You should have a resistor of a few hundred ohms on the base connection of the transistor - that is, between base and pin 13.</p>

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

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

<p>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.</p>

<p>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.</p>

<p>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.</p>

<p>"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 <em>conventional sense</em> - 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*.</p>

<hr>

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