I've done a couple of new schematics, this is my first time doing this, I was wondering if somebody could double check my math?

Powering the RGB LED straight off the GPIO pins:

Using the 5V rail and some transistors:

Thanks, I really appreciate any feedback on this, as I said, I'm just getting my feet wet.


I think it is better for you to use transistors or a driver I.C. such as a ULN2003 instead of driving the LEDs directly from the Pi, so you don't have to worry about drawing too much current from it. Your circuit with transistors looks allright. I would just lower the base resistors a bit so you guarantee the transistors will be saturated when turned on. To guarantee saturation for any transistor a good rule of thumb is to use a base current around 10% of the desired collector current, so if you have Ic=30mA then Ib=3mA. That way, according to ohm's law, Rb should be:

Rb=(3.3-0.7)/0.003=886.66 ohms.

If you choose a 1K resistor you should do fine, as it will yield a base current of

(3.3-0.7)/1000 = 2.6mA.

which is well in the allowed range for the Pi outputs.


Why force transistor to operate into saturation? To avoid beta variability. It is well known the beta parameter can vary in a wide range from transistor to transistor, and with temperature as well. A transistor will be saturated when both its PN junctions are forward-biased, and the effect of this is that its collector current won't rise anymore when its base current rises. See this for some reference about transistor operating regions. I find it easier to understand this when you look at the transistor characteristic curves for its collector circuit, like shown here. Based on that figure, note that when Ib rises (each blue curve is for a specific base current), the transistor operating point (intersection of the red line with the blue line corresponding to your actual base current) will be getting more and more to the left, to a point where even if you use a higher Ib curve the operating point can't go up-left anymore, keeping Ic essentially constant.

When you have enough base current to be on that point, there's no need to increase it anymore, and that rule of thumb of making Ib 10% of Ic is just a generalization so you saturate any transistor, irrespective of their expected beta range. Of course, if you know the minimum beta of a given transistor family you could use smaller Ib than 10% of Ic, but that is just to be on the "always right" for any transistor.

  • Using a Beta value of 75 and the Collector at .03 I calculated the Base at .004 (up from .003/.0004 originally) which by my calculations is ((3.3 - .7) / .004) = 650 ohms ?? where did I go wrong – slf Aug 27 '13 at 21:00
  • Your calculation is right. The problem is to rely on a specific beta value, since it is a parameter that can vary greatly from one transistor to another, even ones from the same manufacturing batch. That means you can't guarantee you will get that exact current with another transistor, and this is why it is better to force the transistor to operate in the saturation region, where beta variability won't be an issue. – Claudio Aug 28 '13 at 12:37

your transistor schematics looks alright, though, I'd recommend using Darlington transistors and forget about all this base current calculations, these will flip like a switch with a very little of base current.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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