Calculationg base-resistor between microcontroller and transistor

I'm curious, when connecting my 2N2222 transistor's base to a PWM output pin on my Arduino, I know the Arduino can deliver a maximum of 40mA current. The 2N2222 only requires around 5 to 10 mA on it's base to switch the collector and emitter. Now, when calculating the base-resistor under "normal" conditions where I'm merely switching it directly from Vcc, the following applies: However, when putting in a 500 ohm or 1K resistor in (1K for 5mA) directly it works great. But putting it in between the Arduino and the transistor, the transistor doesn't switch.

I suspect thus, that the resistance is too high of the base-resistor. Therefore, we may very well not need a base-resistor.

But, according to spec, the Arduino can deliver 40mA. So, am I correct in assuming the folling: 1) I should calculate the perceived resistance that the Arduino is giving, if it goes high to 5Volt and only gives 40mA, and then 2) Subtract that from the 500ohm resistor needed to make the transistor operate optimally.

Example: So, I'm theorising that I have to then put in a 375 ohm resistor in to make the total resistance between the Arduino and the base resistor 500 ohm.

Somehow this doesn't feel right. Keep in mind, I'm not an electronic engineer, so I might have the cat by the tail here :P

• What's the load on the transistor? If you just look at the transistor collector with no load (such as a resistor) to +5 you won't see much going on. – Spehro Pefhany Aug 15 '14 at 10:56
• The load resistance is 2.5 ohm. – Sarel Aug 15 '14 at 17:13
• A 2.5 ohm resistor will cause 2A to be drawn from a 5V supply. That's way more than a 2N2222 can handle. – Spehro Pefhany Aug 15 '14 at 17:20
• Understood, yes, but my supply that I'm using is limited to supplying 700mA. So I'll be drawing all the current I can through the 2N2222. – Sarel Aug 16 '14 at 6:40

You are missing one easy thing: voltage across the resistor won't be 5V.

Transistor side you have a $V_{BE}=V_\gamma\approx0.7V$, so the base of the resistor is about 0.7V lifted from ground.

Microcontroller side, when the output is high you don't have full $V_{CC}$ but a voltage that is somewhat lower. For a cmos chip that can be quite low, some 100mV, but to make the calculations easier let's say you have 0.3V from $V_{CC}$, meaning that the arduino output voltage is only 4.7V.

Let's do the math again:

$$R=\frac{(5-0.3-0.7)\text{V}}{10\text{mA}}=400\Omega$$

Since higher base current is better in this case, just stick with the lowest nearest standard value, i.e. $390\Omega$.

Note: that 0.3V that I wildly guessed is actually written down in the microcontroller datasheet and it's called $\mathbf{V_{OH}}$, as in Voltage Output High. You also can find the $\mathbf{V_{OL}}$ and... Yes, you guessed it, that's Voltage Output Low.
The first one is the minimum output voltage when the pin is set high, if you are within current specs of course, while the second value is the maximum output voltage when the pin is set low.

• @Sarel yep you're welcome, that was just about a little education on how to get the proper value BUT I don't think this will solve your problem. A 20% difference in resistance is nearly within the precision of the resistor itself, you've got something else wrong around. If that does not cut it add a schematic to your question and we'll help you troubleshoot your problem. I need to know especially what you're trying to turn on with the transistor. – Vladimir Cravero Aug 15 '14 at 8:04
• For example, might it be that the arduino works with 3.3V instead of 5V? – Vladimir Cravero Aug 15 '14 at 8:05