# RGB leds color changing help...

Discussion in 'LEDs and Optoelectronics' started by martin the warrior, Aug 18, 2016.

1. ### martin the warrior

35
3
Aug 10, 2015
I am going to be using RGB leds for a project and I am wondering if I can use variable resistors (VR) to control the color... so red led would have a VR blue would have one and so would green... I do not want to use electronics I want to use knobs that I can turn to change the color... this is a rough schematic of what I want... but I do not know if that will control color or not I could not find anything only everything I found people were using microcontrollers... A schematic would be great if this is possible but I am doing it wrong... The reason I feel this is wrong is because I am controlling brightness of each led so it may change the color but it could end up being super bright or super dim depending on the color... so basically on my RGB keyboard I can change color and brightness so I think I am missing control over one of these... now what I think if I put a VR between the fuse and the first branch to the fist VR that would control brightness maybe but I am unsure as well as battery size and minimum VR resistance like 1 ohm to 100 ohms or whatever is best for RGB leds... any help is appreciated...

Last edited: Aug 18, 2016
2. ### (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,497
2,839
Jan 21, 2010
Firstly, a fuse should not be required.

As long as this led is running at low current (say a max of 20mA) then using pots is possible.

If you're using a high power led then it is far less feasible to use pots.

Lets assume it is a low power led. First thing is to calculate the fixed resistor to place in series with each led to set the max current. Then connect an appropriate pot in series with this. The pot might have a max value, say, 100 times the fixed resistor.

Another problem is that this method won't turn off the led. Depending on the value of the pot, it may become dim or very dim.

And yet another problem. The useful range of adjustment may be a small part of the full range of the pot.

martin the warrior likes this.
3. ### martin the warrior

35
3
Aug 10, 2015
okay then how about this. How does a microcontroller control the color and brightness of the LEDs. I would assume that it uses either PWM or resistance (the reason I thought pots would work) and as far as I know that is the two ways you can control current in a system that and a on/off switch... So if I have to use a microcontroller is there an easy non programing way to do what I want. I am setting up a LED system that is completely custom I am not using strips I am soldering LEDs to wires and putting the LEDs in certain areas of my project. Is there something that I can buy that I can hook up to my system and control the LEDs. The whole reason I wanted to use pot is so I don't have to mess with microcontroller programming and stuff. There is a lot of LED strips I can buy that you can change the color of the LEDs is there something I can buy that does not have the LEDs hooked up so I can put in my own LED circuits. I did find this: https://arduino-info.wikispaces.com/RGB-LED in which at the beginning it stats that pots can be used to control RGB LEDs however the diagram is very basic but this is why I thought it was possible to use pots. It does go into using PWM with ardurino but that is not something I want to get into (unless it is the absolutely only way to have what I want) I did also find this as well: http://www.instructables.com/id/Simple-RGB-LED-MOOD-Colour-Potentiometer-Without-M/

Last edited: Aug 18, 2016
4. ### (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,497
2,839
Jan 21, 2010
That instructable is basically what I said.

Controlling by a microcontroller is generally achieved by pwm with a pass element to increase the available current and some means to limit the "on" current.

You need to buy simple RGB LEDs, not those with fancy interfaces.

Last edited: Aug 18, 2016
martin the warrior likes this.
5. ### martin the warrior

35
3
Aug 10, 2015
alright thank you that was very helpful I will be trying it with pots first and seeing if that is want I am aiming for...

6. ### Hellmut1956

53
3
Aug 11, 2014
Why do not take a Raspberry Pi ZERO and modules from China that offer 16 PWM on a cheap board to which you communicate via I2C. I do so to monitor my power panel, has 8 different tensions. For each tension I do use an RGB LED with a transistor to protect the GPIOs of the ZERO. I put a WiFi dongle on my ZERO so that I can monitor and control my panel wireless from my workstation, a PC running Ubuntu. To control the 8 RGB LEDs I need 24 PWMs, so 2 of those inexpensive China boards, 24 PWMs, the ZERO for just 5 USDs. I use QT5 to write a GUI, so that I can control each of the 8 LEDs, 3 PWMs each, using sliders in the GUI, but also being able to input a number between 0 and 100 to specify the intensity of each channel of an RGB-LED.
Additionally the same ZERO monitors the current on each line feeding the panel with its tension using MosFets. The RDSon resistance of the MosFets are used to monitor the current flowing through it. This way I have an "electronic fuse" to protect the lines in my lab.
Remember, a ZERO with a microSD is a full blown Linux system! And all of this so inexpensive!

7. ### (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,497
2,839
Jan 21, 2010
@Hellmut1965, when you say "tension", should I read that as "voltage"?

8. ### Hellmut1956

53
3
Aug 11, 2014
Yes, terrible to always fall in the trap of literally translating when writing in a not native spoken language! But to my contribution. It is lot of fun experimenting and verifying in experiments that what I have in mind actually works as expected or to adapt to what is learned in the excercise!

9. ### Herschel Peeler

401
66
Feb 21, 2016

Select the resistor to set maximum current and brightness level. If V LED is 2 V and +V is 5 V, when the pot is set to minimum resistance the resistor has 3 V. At 20 mA the resistor should be 150 Ohms.
The pot will set minimum brightness. Maybe a 2,000 Ohm pot. So the full range of the pot takes you from minimum to maximum brightness. About 1 mA to 20 mA.

10. ### Hellmut1956

53
3
Aug 11, 2014
Hi everybody. Hope you had a great time over Christmas and my best wishes for all of you in 2019.

Wishing to get ahead with my project of implementing what I call 3rd generation panel:

It is a panel that offers me ways to connect my experiments to a choice of voltages. To the right of the first 4 columns, you can guess there to be a hole, 5 mm diameter next to the switch, same to the left of the switch in those 4 columns. My goal is to have 5 mm diameter RGB LED that shines in the color of the corresponding column. I still have to color some using Revell colors.

The voltages for the columns right to left are:

+24 VDC
+12 VDC
+ 5 VDC
+ 3.3 VDC
- 5 VDC
-12 VDC

The most right column is reserved i.e. to connect the battery pack I am making for my sailboat model,
12 LiFePO4 batteries connected in series which means the voltage will be between approx. +40 VDC and +24 VDC, depending if the batteries are full or unloaded to the tolerable minimum.

The circuitry I am planning to develop starts from the above-shown circuitry to feed RGB LEDs. The RGB LED I did purchase has a common cathode pin. As I am going to have 8 RGB LED in my panel this means I will have to feed 8 x 3 = 24 PWM to define the color in which each LED shines. As the Raspi ZERO W has a too limited number of pins to supply 24 PWM I am using 2 of this PCA9685 board were each of the can generate 16 PWM locally:

Here a picture of the rear of the panel front:

Until I found out that my RGB LED do not have a common anode but a common cathode pin and trying to see what devices would be proper to handle the RGB connections taking into account that a supply voltage of +24 VDC and up to +40VDC would require resistors of pretty high power. The 1/4 W SMD resistors would be OK for the lower voltages, but not for those 2 higher supply voltages.

I had planned to follow the circuitry above but replacing the 5 VDC shown there to come out of the Raspi by feeding the "positive pole" of the column. So I had planned to feed each of the RGB LED by connecting it to the receptacles above the switch. So the switch in the "ON" position, receptacles above the switch get their positive connected to the power source and the RGB LED is powered. Switching the switch to the "OFF" position and the RGB LED would be OFF.

Now my questions:

1. How does the circuitry change from the above-shown drawing?

Is it that I do have to connect GND to the cathode pin of the RGB LED and replace the GND connections in the drawing of the BC547 with the "Positive pole?

Or would I have to use PNP transistors in replacement for the BC547?

Would I have to connect the ground line of each voltage colon to the switch so that the RGB LED and the receptacles above the switch, so far I had planned to connect the positive poles to the switch to disconnect the receptacles above the switch and the RGB LED?

2. This question is related to my need to reduce the voltage fed to the RGB LED using a switched DC-DC converter to 5 VDC so I could use the 1/4 W SMD resistors. Also, the heat generated when a resistor is used to limit the maximum current through the LED to 20 mA would be intolerable.

Is it OK to also reduce the negative voltages, -12 VDC and -24 VDC using one of ma DC-DC switched converters by connecting the converter to GND which is the higher voltage and the "positive poles" here -12 VDC and -24 VDC? This voltage reductions, -12VDC to -5 VDC and -24 VDC to -5 VDC would be used exclusively for feeding the corresponding RGB LED and not the other receptacles to the transistor?

I hope I have been able to have given you the background information for my questions. I have not advanced my soldering work between the receptacles of the panel due to this questions I need to resolve upfront.

11. ### Harald KappModeratorModerator

11,644
2,691
Nov 17, 2011
tension = mechanical (German: Spannung)
voltage = electrical (German: Spannung)

12. ### Harald KappModeratorModerator

11,644
2,691
Nov 17, 2011
1.
That's the way:

2.
I suggest you do not use the various voltages to directly power the LEDs. Use the 3.3 V or 5 V supply as "VLED" (see my schematic). Use the control pin to turn an LED on or off.

As for the pwm: usually pwm is used to control the brightness of LEDs in a quasi-analog manner (dimming). I do not see why this should be necessary here. Your panel shows 5 different colors
which can be generated in a simple fashion:
• white: red + green + blue
• red: red
• green: green
• blue: blue
• yellow: red + green
For each color a simple series resistor will suffice. There is no difference in power consumption compared to pwm (unless you dim the LEDs):
Assume a forward voltage of 2 V (which is a median value for the different colors) and a supply voltage of 5 V. Assume also an ideal switch (transistor). LED current is 20 mA.
1. linear:
R = (5V - 2 V)/20 mA = 150 Ω
total power = Ptot = 5 V * 20 mA = 100 mW
2. pwm:
50 % ducty cycle, 40 mA current for the same average brightness
R = (5 V - 2 V)/40 mA = 75 Ω
total power = Ptot = 5 V * 40 mA * 50 % = 100 mW

13. ### Hellmut1956

53
3
Aug 11, 2014
The RGB LEDs have to get OFF when the corresponding switch is OFF. That is my justification to feed each RGB LED using the positive pole taking it from the positive pole circuit above the switch. I want to be able to control the color of each RGB LED from a window on my W10 Pro desktop. So by having the controls for the individual 24 PWMs in that window, I can control color and intensity.

The colors of the voltage receptacles will be different for all 8 voltages that will be available. I just have been too lazy to color all the corresponding plastic elements of the receptacles.

@harald: Having to take the "positive poles" I need 2 slightly different for "positive" poles and for those of negative voltages. The other aspect is those feeding voltages of +24 VDC and +24 VDC to 40 VDC means that the resistors have to burn a lot of energy. Here I plan to use switching voltage regulators that make available + 5 VDC. Then I can use the resistors of 1/4 W SMD versions.
But nevertheless thanks.

14. ### (*steve*)¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥdModerator

25,497
2,839
Jan 21, 2010
Thanks for that explanation Harald. I wonder if that is why we sometimes refer to high voltage as "high tension"?

15. ### Harald KappModeratorModerator

11,644
2,691
Nov 17, 2011
As far as I can see you turn the voltages on and off using mechanical switches. If you use double pole double throw switches, you can use one pole to turn the output voltage on and off and the second pole to control the LED - completely independent from the voltage that is switched.

Seems very likely to me.

16. ### Hellmut1956

53
3
Aug 11, 2014
Sorry for being so bad to make me understood. @Harald: The LED has to switch ON/OFF by the switch to indicate that the receptacles above the switch re either ON or OFF.

17. ### Harald KappModeratorModerator

11,644
2,691
Nov 17, 2011
There's nothing bad in your post. I didn't want to imply that.
That's exactly what my proposal does. Use one pole of the switch to turn the power on or off, use the second pole to turn the indicator LED on or off. You can control hue and brightness of the respective LED by selecting the appropriate series resistors.

18. ### Hellmut1956

53
3
Aug 11, 2014
That is what I do. I want to control the brightness and the color using PWM remote controllable from my PC by placing a window with the desktop of the Raspi Linux in which an application implements the GUI. But that does not deal with what I asked for help.

The questions and the background information is in my first contribution in this thread.

19. ### Harald KappModeratorModerator

11,644
2,691
Nov 17, 2011
I think it does. As I understand it you want to power the LEDs from the respective output voltages (that's question #2 about the dc-dc converters). What I'm trying to tell you is that this is in my opinion unnecessarily complicated. You can use one pole of the switch to switch e.g. the -12 V supply on or off. You use the second pole of the switch to drive the LEDs. You may use the raspberry and pwm if you're so inclined, there is no contradiction.

20. ### Hellmut1956

53
3
Aug 11, 2014
OK, I think I understood your proposal now. You are talking about using a 2 pole switch instead of the 2 pole switch I am using right now. On the second pole of the 2 pole switch, I always connect a 5 VDC which is used to switch the supply of the LED ON/OFF in parallel to the first pole which connects the receptacles above the switch with the voltage of the corresponding column. The result would be that all RGB LED circuits would be fed with 5 VDC. Right?