# RGB led: can I put only 1 resistor at ground?

Hi,

I know that if I have an LED I can put the resistor like this:

digital output -> resistor -> led -> ground AND digitar output -> led -> resistor -> ground

Both ways above will provide the same amount of current. Ok, I understand that. So why do I need always 3 resistors when using an RGB led? Take a look at this image:

http://www.comofazerascoisas.com.br/posts/arquivos-posts/157/projeto-arduino-led-rgb-06.jpg

In that image (I got it from the post at http://www.comofazerascoisas.com.br/projeto-arduino-controlando-led-rgb-multicolorido.html) the guy uses 3 resistors of 330 ohms each. I understand the reason he used 330 ohms cause this will keep the current under 40mA. But my question is this: why this guy didnt use only one resistor of 330 ohm at the ground?

Why does he use 3 resistors of 330ohm if he could use only 1 resistor of 330ohm conncted to the ground (hi his example latter he will plug all the 3 leds at the same ground, so why not using 1 resistor instead of 3)?

Won't work, need 3 Rs.

1. with just one series-R, when you turn on 2 or more Leds, then the current will split 2 or 3 ways, and the brightnesses will be lots dimmer than with 3 series-Rs. In the latter case, the 3 Leds are effectively totally independent of each other.

2. with only one R, the green and blue Leds will never light, because Vf(orwards) for the red led is only 2.1V and it's a much higher 3.5V for the other two, and you have all 3 wired effectively "in parallel".

You need to understand "circuit theory" to understand this last statement - so you should go somewheres else and learn about all the basics.

Good stuff here:

It is possible to use only one resistor by multiplexing the LEDs.

Turn on red, turn off Turn on green, turn off Turn on blue, turn off Repeat

If varying the on-times you get different colours and brightness.

Pelle

Wow what a trade off. All that multiplexing to save two \$0.01 resistors.

Wow what a trade off. All that multiplexing to save two \$0.01 resistors.

LOL

Grumpy_Mike: Wow what a trade off. All that multiplexing to save two \$0.01 resistors.

The question was: Can I only use one resistor?, yes Nothing about money!

Take two \$0.01 resistors, add cost to place them on board, multiply with 100000000 pc = lots of money

If you only make one pc, if it's possible why not do it.

Pelle

if it's possible why not do it.

Cos it is stupid. Can you not see that? As is this:-

Take two \$0.01 resistors, add cost to place them on board, multiply with 100000000 pc = lots of money

Have you ever designed a mass production consumer electronics product? I have and that argument is not valid.

Nobody makes 100 million of anything. Even if they did what makes you think resistors are as expensive as \$0.01 each at this sort of quantity? Have you seen the quotes to have something made with two less resistors? They are identical. To get the brightness the same you have to run the LEDs at a higher current. That will affect the reliability of the circuit and hence the return rate, any notional savings quickly turn into a large loss.

I have the last 35 years designed and produced proffesional electronics, all time trying to reduce costs. It's better with 50 rows of code instead of hardware. Sometimes I do not have space for 2 resistors, perhaps we can make a solution in software instead.

Whats the problem with multiplexing LEDs, that's made for decades, look at most multidigit displays. At this forum there are made cubes with multiplexed LEDs, did they burn? Of course you must check the datasheet for peakcurrent and powerdisipation.

If you ask for a quote, the manufactor counts the number of components, I do it.

It is stupid to say it's stupid when it's possible.

Pelle

If you ask for a quote, the manufactor counts the number of components, I do it.

This is kind of going off the deep end here. OP is clearly at the stage of needing to learn the basics, rather than build 100,000,000 boards.

Addressing this back to OP = gilperon, the “learning curve” says learn the basics first, then learn the clever hacks after a while. It will take you 2-pennies to solder in 2 additional Rs, and 2-days to figure out how to multiplex a bunch of Leds.

One issue with the RGB Led is the individual Leds have both different Vf as mentioned, and also different brightnesses in the 3 Leds. Typical, Red = 2.1V and 3000 mcd, Green = 3.5V and 5000 mcd, and Blue = 3.5V and 1000 mcd. Normally, people don’t care, but having 3 series-Rs allows you to use different R-values and set different currents in the 3 Leds, and therefore compensate for the different brightness characteristics, if you need to.

I understand the reason he used 330 ohms cause this will keep the current under 40mA.

Also, these things are VERY bright. 40mA is a lot of current for hi-brightness Leds. Even at 10mA, the RGB Leds are so bright they’ll bleach your photoreceptors in a couple of seconds at 2-foot distance.

BTW, his 330 ohms at Vcc=5V will drive only (5-3.3V)/330 = 4.5mA into the GB devices, and a little more into the R device. In my currently inprogress project, where the RGB is used as an indicator, I’m cutting the currents back to about 2 mA, just because they are so bright. So, more like 680 ohms.

One other issue is that people will immediately start talking about using extra driver stages, like NPN inverters, etc, in order to offload the Led currents from the processor I/O pins. This was more necessary when driving older Leds that did take 20-40 mA to get adequate brightness, than when using the newer hi-brightness Leds. In my project, I’m driving upwards to 20 indicator Leds, and the current is only in the range of 40-50 mA total, which is no problem for an Arduino chip.

I would connect it like this for a 3 color status indicator and use PWM for intensity control.

To get both colour mixing and intensity control, I think multiplexing 3 PWM signals might not be too difficult. Each PWM signal (R,G,B) could have its own duty cycle range that matches color brightness. When multiplexing sequentially one LED at a time, the other 2 LEDs would be turned off.

dlloyd: I would connect it like this for a 3 color status indicator and use PWM for intensity control.

To get both colour mixing and intensity control, I think multiplexing 3 PWM signals might not be too difficult. Each PWM signal (R,G,B) could have its own duty cycle range that matches color brightness. When multiplexing sequentially one LED at a time, the other 2 LEDs would be turned off.

Why do you guys insist on trying to get a beginner (??) to do things the hard way when all he needs is 2 extra 1-penny resistors to do it the easy way. Go look up the concept of the Learning Curve. First you learn the basics, to get a firm foundation in what you're doing. Later on, you can do all the fancy dancy stuff you want.

I have the last 35 years designed and produced proffesional electronics,

Glad you never worked for me then.

Be cool, Mike. These guys are not addressing the actual problem that gilperon brought to the thread. Their past lives are irrelevant. 100,000,000 boards is not relevant.

In that image (I got it from the post at http://www.comofazerascoisas.com.br/projeto-arduino-controlando-led-rgb-multicolorido.html) the guy uses 3 resistors of 330 ohms each. I understand the reason he used 330 ohms cause this will keep the current under 40mA. But my question is this: why this guy didnt use only one resistor of 330 ohm at the ground?

Why does he use 3 resistors of 330ohm if he could use only 1 resistor of 330ohm conncted to the ground (hi his example latter he will plug all the 3 leds at the same ground, so why not using 1 resistor instead of 3)?

I answered gilperon it is possible to use only one resistor if he/she multiplex the RGB LEDs. Mike started talking how cheap resistors are (they are not free of charge and take place). Mike told me how stupid I was, well... I'm only a farmers boy but worked with construction and manufactoring electronics for many years. Always optimizing costs for components, assembling and service.

100 million was perhaps a little bit to much but look att the computerindustri if the can eliminating one component.

I answered gilperon it is possible to use only one resistor if he/she multiplex the RGB LEDs.

That's a nice clever hack, but I figure new people need grounding in the basics first. Secondly, you're trading off using two 1-cent Rs against 2 days or so of coding, especially for a new programmer.

Thirdly, multiplexing makes much more sense if you're using more Leds than you have I/O pins available. Fourthly, it takes quite a lot of cpu cycles to execute proper multiplexing [ie at rates above the flicker-fusion frequency of human vision], and that bites into resources available to do everything else - especially if interrupts are used.

Fifthly, it's easy to simultaneously PWM the 3 channels of the RGB, if separated by 3 Rs, and get 256 hues and 256 or so brightnesses, which is a major reason people use RGBs in the first place. Trying to do this via any multiplexing scheme with only one R would be a real dog to code, and hardly worth the effort [except maybe for bragging rights].

All these things should be explained to a beginner, so they understand the issues on each side.

I consider myself a beginner and while I do understand it might be simpler to wire 3 resistors I do understand Pelleplut point. On top of that having a software background for me might be easier to code the PWM rather than walk to the local shop and pay 0.50 for 3 resistors (that's the price I get for low volumes locally).

Now, being a beginner I say the answers "no, you can't" are not making a beginner's life easier, especially when, later on, you start understanding you can do it! If you want to make life simpler to the guy because you think he is a beginner then just say "you can, but it's a lot more complicated than just using 3 resistors and involves some complicated coding we advise against", but when someone else comes in and says "it can be done" then you shouldn't state that he, or his suggestion, is stupid, simply because it's not and it's answering the exact question!

I'm here to learn and I believe Pelletplutt gave his perspective to the question: it's a valid and working solution. The OP never asked for the cheapest solution, and even if he did, it would be a lot cheaper for me to write down the code and use 1 resistor... not everybody has a shelf full of all kind of passives you pros certainly have. And because I've already spent 20\$ on my Arduino board and it's sitting there doing nothing I might prefer to have it's loop function doing something better than just running delays over and over.

Now, I'm not saying I would go for Pelleplut's solution, but certainly I do not consider what he said neither stupid nor wrong. It was actually wrong and pretentious to say it was stupid, as much as it is wrong to keep saying it's a less valid solution because of OP knowledge, resource usage and such... the question never mentioned that.

Well, cool. You can settle one point. See how long it takes to actually code the multiplexing scheme, and I mean actually get multiple LEDs to work in some reasonable way, and not simply code up a simple for...loop, and say it works.

Easy enough. Now, inject that routine into another program that is doing something non-trivial, that has some other timing constraints, and things start to get more interesting. You're essentially writing your own simple multitasker just to keep your LEDs from flickering.

Now try to change the RGB hues and intensities to given values using your multiplexing scheme, and then report back how much work the 3 programs took to accomplish. Now, you're learning quite a lot by this time.

Keeping in mind that, due to all LEDs sharing a single resistor, you cannot have any two LEDs on at the same time. So if you want each color to have a full range of brightness regardless of the other colors states, each can only have a maximum of 1/3 duty cycle.

Which means you will probably need to boost the peak current. As even 40mA is too much to draw from an Arduino pin (never use the full ratings, always derate by 2x or more), you'll need driver transistors. But those require current limiting resistors on their bases.

This multiplexing thing all sounds pretty darn simple .... until you actually try to get it to work, and work [u]well[/u]. That's the real proof of the pudding.