In the off state, (I/o pin low), no current will flow into the pin.
In the on state (I/o pin = high), let's say the worst case would be when the buzzer resistance is zero and saturation voltage of then npn is 0.
Then, assuming a 5v micro, the R1 (100 ohms) allows 50mA to flow. If Hf is 150 (worst case), the collector current is 50mA *149/150 = 49.666 mA.
Therefore, the load on R2 does not exceed 340 micro amps.
Or, if we correct for the 0.6V b-e of the Transistor, the emitter is 4.4v above ground.
4.4v * (R1 * (1+Hf)) = 304 microAmps.
OK, let's assume I am following all of this fictitious EE gobbeldygook (relax, I am kidding, thanks for responding).
So, if I want to switch a piezo buzzer with a GPIO, I ask myself....how much current is that buzzer going to take?
I hook up the buzzer to a hefty power supply and it buzzes as it should and I put my meter in there and I read - 14.1 mA at 3.3V and 21.2 mA at 5V [ I just did this - removed the piezo and hooked up the meter].
So, lets say I am using a 5V GPIO and 21.2 mA is above the comfortable drive capability (some can provide 25mA and some can only provide 4-5 or less), so this is not a contrived question.
Now I am thinking... well have the GPIO drive the base of NPN transistor which will switch the buzzer on and off.
So, armed with the specs on the transistor (I linked those earlier), I look up, how to calculate the base resistor to saturate the transistor .....and I find many such threads...
such as
But I don't see where any of that information leads me to a 51 ohm resistor. I am completely serious and have no embarrassment about it at all - I simply am not seeing that.
crutschow , in one of those threads said "A proper design that will work over a wide temperature range and with any BJT should have a base current of 1/10 (or perhaps 1/20 with high gain transistors) of the maximum collector current." Yes, it is out of context, but I don't see that guideline being used here - or the general formula in that thread - or the calculations in the stackexchange thread. I just don't get what would lead someone to calculating a base resistor of 51 ohms in that situation.
Can you shed some light on that? if I understand "Therefore, the load on R2 does not exceed 340 micro amps.", the transistor is not saturated ?- it is not operating as a switch? Or why not use a 500 Ohm resistor for R2. How much current is the GPIO providing - 340 microamps? Is that the truth?
I hate this stuff - it makes no sense and it gives me a headache.