I am trying to add a custom LED lighting setup to my desktop gaming computer. In this setup I want small sets of LEDs to be able to be turned on separate of other sets. This is so that I can turn on different sets at different times to make a "light show".

I am using an Arduino's digital I/O pins to control a transistor (BC547B) which will supply power from a 9-volt battery to the LEDs. The LEDs are rated at 1.9v and I have multiple sets of 5 LEDs (5 * 1.9 = 9.5 -- no need for a resistor... right?) connected in series and those "multiple sets" are to be connected in parallel.

However, due to a simple lack of transistors, I am temperarily (until I get more transistors) connecting 2 sets of the 5 LEDs per transistor. Confused? Let me put this together in a schematic using only 1 transistor (in the final version there will be more):


simulate this circuit – Schematic created using CircuitLab

So, basically the problem is, when I turn on pin 5 on my Arduino, the LEDs do not light up. Why is this?. I may be doing something wrong here, but, if I am, I cannot figure it out.

Here is the temporary code for the Arduino I am using, just in case someone wants to see it:

void setup() {
    pinMode(5, OUTPUT);

void loop() {
    digitalWrite(5, HIGH);
    digitalWrite(5, LOW);

All it does is turn pin 5 on, wait a second, turn it off, wait a second, and repeat.

Thanks in advance.

P.S. Apologies for awkward title.


I should also note that I'm very new to this kind of stuff. I'm doing this for a sort of learning project (and so my computer can look cool).

  • \$\begingroup\$ I take back my flag. This requires a more in-depth answer. Also, +1 for asking a clear question complete with a good schematic, code, good grammar, and a thorough explanation! \$\endgroup\$
    – uint128_t
    Feb 16, 2016 at 5:55
  • \$\begingroup\$ You have too many leds in series for your 9V .Try 3 .Dont use your follower because there wont be enough volts from the micro to drive it .Use an open collecter and do a proper current sink for the series strings. \$\endgroup\$
    – Autistic
    Feb 16, 2016 at 19:05

1 Answer 1


First off, the whole "5*1.9V = 9.5V -> no need for a resistor" isn't going to work. The forward voltage is not exact, and neither is your 9V. Here's an explanation of why forward voltage == supply voltage is an issue. Also, there's going to be some voltage drop across your transistor.

Your circuit has many issues.

  1. To turn on the transistor, the Arduino would need to output 5*1.9V + ~0.7V = ~10.2V. The Arduino pins output 5V, so that's a no go right off the bat. If you ground the emitter and connect the LEDs to the collector, that's much more likely to work.

  2. Your transistor needs a base resistor to limit current through it. You risk damaging your Arduino and your transistor. When saturating the transistor (which is what you want to do to get it to act like a switch), the base will be at ~0.7V. Without a base resistor, the Arduino pin drives that to 5V and a whole lot of current flows into the base, burninating the poor Arduino. Hence, a base resistor is required; its value is dependent on how much current you want through the LEDs and the current gain of the transistor. Without doing the math, something between 220Ω and 1kΩ is probably good.

  3. LEDs or LED strands in parallel need individual resistors. There are many answers on this site that can explain why in greater detail; basically, the net forward voltage across different LED strands will differ, causing current imbalance. Mathematically, \$\frac{V_s-nV_f}{I_f} = R\$, where \$V_s\$ is your supply voltage, \$n\$ is the number of LEDs in a series strand and \$V_f, I_f\$ are the LED forward voltage and desired forward current, respectively.

  4. When you do get this working, your 9V battery probably won't be adequate (9V batteries have very little capacity and low current capability). A 9V wall wart or similar would be much more appropriate. Also, that transistor is only rated for a maximum of 100mA collector current. A few LED strands will exceed that and your transistor will be toast. A bigger transistor, or better yet, a nice beefy MOSFET, will ensure you can safely switch many LEDs. For a single strand, or maybe two, that transistor is fine. If you are using a 12V PC PSU, that's fine, just make sure to calculate your current limiting resistors with 12V instead of 9V.

So, use four LEDs in series and an appropriate current limiting resistor, change the connections of the transistor, and add a base resistor. That should at least get you started.

  • \$\begingroup\$ Ok thanks! A few questions though. First, for point 2, where does that resistor need to go? On the base pin of the transistor? Also, for point 3, are you saying I need a resistor in front of each LED strand? And yes the 9v battery was temporary; I forgot to mention that. I plan on just connecting to a 12v molex connector on my computer's power supply. \$\endgroup\$
    – RobertR
    Feb 16, 2016 at 5:56
  • 1
    \$\begingroup\$ Yes, base resistor goes between the base and the ATmega. And yes, you need a resistor in series with each LED strand to limit current. I'll expand my answer to cover some of your questions. \$\endgroup\$
    – uint128_t
    Feb 16, 2016 at 5:59
  • 1
    \$\begingroup\$ w.r.t point 4: if the LEDs are to be flashed with a fairly low duty cycle, a big electrolytic capacitor in parallel with the battery might help. Just be sure to get one rated 15V or more (i.e. over-specced). \$\endgroup\$
    – Chris H
    Feb 16, 2016 at 12:46
  • \$\begingroup\$ Ok so one more question: what would the resistance of the resistor mentioned in point 3 be? Using Ohms Law via the equation you provided, it would be (9 - 9.5) / 0.04 = -12.5. The value of 0.04 is used for the forward current because each LED is rated at 20mA and I have 2 strands in parallel thus the overall forward current is 40mA or 0.04A. \$\endgroup\$
    – RobertR
    Feb 17, 2016 at 0:50
  • 1
    \$\begingroup\$ Yes, that's hint why you shouldn't use 5 LEDs in series. As I stated earlier, you should have a separate resistor for each strand, so if you were to use 4 LEDs in series with a resistor the math would be (9V-4*1.9V)/20mA = 70Ω. \$\endgroup\$
    – uint128_t
    Feb 17, 2016 at 2:51

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.