1
\$\begingroup\$

I have a very basic LED circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

All D# are 3Vx0.02A LED. In order for this circuit to work, we need a 25Ω resistor for each LED quartet:

Total LEDs current = 0.02A*4 = 0.08A
Voltage drop = 5V - 3V = 2V
Resistor value = 2V/0.08A = 25Ω

I didn't have a 25Ω resistor, so I put a 27Ω resistor instead.

Now, I want to add an Arduino in order be able to power on and off each LED quartet programmatically. I don't want to overload the Arduino, so I thought it would be ok to have an external power supply which will give the LEDs all the current they need to work, without worrying about burning the Arduino itself.

I thought I could either use transistors or MOSFETs as logical on/off switches, but I chose transistor because they are way less expensive than MOSFETs.

I thought about getting a 2N3904, because it supports up to 200mA and the circuit requires 0.08A per LED quartet.

So far I know the circuit should look something like this:

schematic

simulate this circuit

I'm definitely not an electronic expert, I assumed it should be like that because I looked a site which talked about Arduino controlled LEDs via transistor used as on/off switches. It didn't explain a thing, it just had the circuit so what I want to ask is: why the 10kΩ resistor? Is the value right? Do I need a 1/4W 10kΩ resistor or a 1/2W one? The 27Ω resistor should remain 27Ω or should be changed when a transistor is introduced?

\$\endgroup\$
2
  • \$\begingroup\$ It is usually a bad idea to groups LEDs together using only 1 current limiting resistor. This could lead to all kinds of problems such as unevenly lit LEDs. \$\endgroup\$
    – st2000
    Dec 24 '16 at 19:30
  • \$\begingroup\$ The above statement is pretty much FUD at this point. If you understand how leds work, paralleling them is fine. Look at any battery powered led string. All those leds are in parallel \$\endgroup\$
    – Passerby
    Dec 24 '16 at 20:03
3
\$\begingroup\$

Your basic concept is right, but there are some issues:

  1. Paralleling 4 LEDs is not a great idea. It would be better to give each LED its own resistor. You say the LEDs drop 3 V. Figure about 200 mV for the saturated transistor, which leaves 1.8 V across the resistor. (1.8 V)/(20 mA) = 90 Ω. The common value of 100 Ω would work fine.

  2. You have to consider the gain of the transistor in determining its base resistor. As you say, the transistor will pass 80 mA when on. Let's say we want to run the transistor at 20:1 collector/base current, since it can be counted on to have more gain than that. That means you want about 4 mA base current. If the digital output goes to 5 V when high, you have about 4.3 V across the resistor. That comes out to (4.3 V)/(4 mA) = 1.08 kΩ. We have some slop in the calculations so 1.1 kΩ should work fine.

    In any case, 10 kΩ is likely too high. Working backwards, that provides 430 µA base current, which means you are relying on the transistor to have a gain of at least 186. That is well above the guaranteed minimum, so 10 kΩ is clearly too much resistance.

\$\endgroup\$
9
  • 1
    \$\begingroup\$ which means you are relying on the transistor to have a gain of at least 186 - The datasheet says that the maximum HFE is 300. Is this information useful? Does it change something? What does it mean that HFE@100mA can be as low as 30 up to 300? Also, the datasheet says that the transistor collector/emitter voltage is 1V. Does this mean that the transistor will have a voltage drop of 1V, so I have to re-calculate the LED-resistor value for 0.8V drop instead of 1.8V? \$\endgroup\$
    – BackSlash
    Dec 24 '16 at 19:42
  • \$\begingroup\$ Typo, I think, in your last sentence. You mean 10 k and not 1 k. \$\endgroup\$
    – jonk
    Dec 24 '16 at 19:43
  • \$\begingroup\$ @Back: Maximum Hfe is irrelevant here. We have to design the circuit to work with the smallest gain the transistor might have. In this circuit, higher gain causes no problem, and it would work with infinite gain just fine. \$\endgroup\$ Dec 24 '16 at 20:03
  • \$\begingroup\$ @OlinLathrop What about the question on the voltage drop? \$\endgroup\$
    – BackSlash
    Dec 24 '16 at 20:08
  • 1
    \$\begingroup\$ Whoever downvoted this, what exactly do you think is wrong, misleading, or badly written? I'm not seeing it. \$\endgroup\$ Dec 24 '16 at 20:09
0
\$\begingroup\$

The 10K ohm resistor is there to reduce the current the Arduino's output will need to provide. Otherwise the Arduino will be "looking at" about 0.6 volts which it will try to pull up to about 5 volts. Something will have to give and it will probably be the Atmel processor's output.

So, that is why you need to go through a resistor. But why 10K ohms? Most common transistors will have a beta of about 100. That is, the base to emitter current x 100 is about equal the collector to emitter current.

So, the current in the base to emitter path is ((5V - 0.6V) / 10,000) or about 0.44mA. Multiply that by 100 gets you 44mA for the collector to emitter current. Which is less than the 80mA you had calculated was necessary. So your circuit may not work. To make a circuit that will work consider changing this resistor from 10K ohms to 5K ohms or even 1K ohms.

Also, you should avoid grouping LEDs using a common current limiting resistor. This could lead to several problems. One of which could be unevenly lit LEDs. Instead consider the following example from http://playground.arduino.cc:

enter image description here

If you want to read more about using transistors as switching read this web page.

\$\endgroup\$
7
  • \$\begingroup\$ Thank you! What about the resistor? Should it be a 1/4W one or a 1/2W one? Also, the datasheet says that VCE is 1V: does it mean that I should change the 27Ω resistor to a 15Ω resistor (voltage drop of 1V instead of 2V)? \$\endgroup\$
    – BackSlash
    Dec 24 '16 at 19:26
  • \$\begingroup\$ I did not build the circuit yet, I'm trying to understand if it is right before doing anything, also because I still need to buy some parts so I want to be sure everything is correct before buying. You talk about beta: I can't find it in the datasheet, is it the HFE? If yes, the datasheet says that with 100mA of collector current, the HFE goes from a minimum of 30 to a maximum of 300. Which value should I consider and why? \$\endgroup\$
    – BackSlash
    Dec 24 '16 at 19:34
  • \$\begingroup\$ Well, I think your circuit will not work because the beta (Hfe) is only 100 and the current going into the base is too low to support passing 80mA from the collector to the emitter. So, if it works, great, if it doesn't, consider reducing the 10K ohm resistor to 5K ohms or even 1K ohms. At 1K ohms the current would be increased from 0.44mA to 4.4mA. This is still very low and you can get by with a very low wattage resistor. \$\endgroup\$
    – st2000
    Dec 24 '16 at 19:38
  • \$\begingroup\$ Those Hfe values are the range you might find in a batch of transistors. Again, you are mostly interested in cut-off and saturation. (We're not building a high end amplifier here using transistors with matching Hfe's.) All you need to do is make sure the circuit will work. Using 10K ohm may or may not work, using 5K ohms might work and using a 1K ohm will probably work. \$\endgroup\$
    – st2000
    Dec 24 '16 at 19:42
  • \$\begingroup\$ Ok that's clear. Last question (in the first comment): Right now the LED resistor has a voltage drop of 1.8V; the datasheet says that the collector/emitter voltage for the transistor is 1V. Does this mean that the transistor has a voltage drop of 1V and I should re-calculate the LED resistor value for a voltage drop of 0.8V instead of 1.8V? \$\endgroup\$
    – BackSlash
    Dec 24 '16 at 19:47

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.