RGB LED circuit - Page 1
Forum section: electronics / beginners

author: darinsquared
author_rank: Contributor
timestamp: February 10, 2018, 04:12:47 pm
content: I want to make a LED light (6-8 LED's) with RGB LED's. When the main switch is ON I want the Red to illuminate. I also will have two momentary switches in the circuit. When I hold one switch the green will illuminate and when I hold the other switch the Blue will illuminate. I am not sure how to design this circuit. Would it be simpler to have three sets of colored LED's?

author: Zero999
author_rank: Super Contributor
timestamp: February 10, 2018, 04:44:27 pm
content: Quote from: darinsquared on February 10, 2018, 04:12:47 pmSo you mean, with power on and no switches are pressed, the red light will be on, when one switch is pressed, both red and green will be illuminated, producing yellow light and when the other switch is pressed, the blue LED will light, giving magenta light and when both switches are pressed, all the LEDs will light giving white?Start with a table showing what colour light is desired, when different switches are pressed. It's possible this can be implemented passively, with just switches and current limiting resistors. Another possibility is diode logic, logic gates (74HCxx is probably best here) or a microcontroller, f more than four gates are required.

author: Nusa
author_rank: Super Contributor
timestamp: February 10, 2018, 04:58:33 pm
content: ^^ What he said about design clarification.Separate sets would be cheaper, space and other considerations permitting, but they're almost the same thing electrically. The basic version of RGB LED's are just 3 LED's in a four-pin package, with one pin for each color and a common anode or cathode (you can get them either way - that means all 3 LED's are connected together on one side only).

author: darinsquared
author_rank: Contributor
timestamp: February 10, 2018, 07:04:37 pm
content: sorry for poor explanation. Yes red is on with "main" on switch. I will then have a switch for Green and switch for Blue. I am making a light to guide direction. So when no switch is pressed this tells people to stop. If I want them to move forward I will press switch for green lights and the red turning off. When switch is released the red comes back on indication people to stop. Blue light works the same to notify moving backwards/reverse.I am maybe leaning towards having three individual lights and using a three position rotary switch. I was only considering RGB LED's for saving space.

author: Cyberdragon
author_rank: Super Contributor
timestamp: February 10, 2018, 07:54:12 pm
content: Just have the red on an inverter and connected to the other two buttons. You could be dirty and just short the LED with a transistor across it. Or you could use something more efficient like this. Note: remember to use diodes between the switches and inverter input or both lights will come on together.If you're using batteries, use the more efficient method as the shorting method wastes power and can stress the resistor depending on the power levels in this circuit.

author: Zero999
author_rank: Super Contributor
timestamp: February 10, 2018, 09:11:45 pm
content: Quote from: darinsquared on February 10, 2018, 07:04:37 pmA NOR function is required. This can be implemented as an AND with the two inputs inverted, or just a NOR gate. See attached schematics. The right one shows a NOR gate. The left and middle, an AND gate with the inputs inverted. The left one uses two normally closed contacts, both in series with the red LED. The middle, two transistors, which aren't critical: the 2N7000 will do. When the push-button switches aren't pressed, the transistors will both be on, because their gates will be near +V. When a switch is pressed, to turn the green or blue LED on, the gate is pulled down to 0V, causing the transistor to turn off. Because the transistors are in series, they both need to be on for the red LED to light.The resistor values can be calculated, using the calculator linked below:http://www.ohmslawcalculator.com/led-resistor-calculator

author: phil from seattle
author_rank: Super Contributor
timestamp: February 10, 2018, 09:38:13 pm
content: One RGB or 3 separate LEDs makes no huge difference. But figuring out your interface does. That will drive the actual circuit.Your 3 way switch approach is conceptually simple - just 3 separate circuits. Make the middle one red so it's the intermediate state. Then it's just the LEDs and current limiting resistors.A more elegant solution is to have two buttons - one for forward, one for back. When neither are pressed, red lights up. There are some simple circuits to do this. See the schematic for one. D1 and D2 are any small diodes - 1n4148 is a common one.How will you turn this whole thing on/off?

author: Zero999
author_rank: Super Contributor
timestamp: February 10, 2018, 10:35:08 pm
content: Quote from: phil from seattle on February 10, 2018, 09:38:13 pmThe problem with using a silicon diode is, it will have the same voltage drop as Q1's base-emitter junction, which will mean Q1 will not properly turn off and R5 won't help matters. Use Schottky diodes, omit R5 and reduce the value of R4, to give Q1 sufficient base drive.QuotePresumably a toggle switch?

author: hamster_nz
author_rank: Super Contributor
timestamp: February 10, 2018, 10:54:25 pm
content: You could do this purely mechanically, with a single pole toggle switch to turn it the power on, then two dual pole dual throw (DPDT) pushbutton switches for the green and blue LEDs.Wire the normally open contact of one pole of the "green" pushbutton to turn on the green LEDs, and likewise wire the blue LEDs to the other push button.Then wire the other pole of the two pushbuttons in series, using the normally closed contacts to the red LEDs. That way when either button is pushed the red LEDs will be extinguished.Piece of cake.Have you considered using 12V RGB LED strips? The resistors are build into the strips, and they usually use a common anode (positive) connection - you will then need to put your switches between the negative battery terminal and the strip. Were you to do this you would only need the battery/power source, an LED strip, the three switches and some hookup wire.

author: phil from seattle
author_rank: Super Contributor
timestamp: February 11, 2018, 05:58:10 am
content: I simulated the circuit on LTSpice and it works just fine. The silicon diode drop isn't that much.

author: StillTrying
author_rank: Super Contributor
timestamp: February 11, 2018, 04:08:36 pm
content: Simples.

author: phil from seattle
author_rank: Super Contributor
timestamp: February 11, 2018, 04:47:09 pm
content: Quote from: StillTrying on February 11, 2018, 04:08:36 pmheart of simplicity. that one gets my vote.

author: Zero999
author_rank: Super Contributor
timestamp: February 12, 2018, 10:14:18 am
content: Quote from: phil from seattle on February 11, 2018, 05:58:10 amSo have I. The silicon diode voltage drop, is still enough to bias Q1 into conduction, causing the red LED to dimly light. Removing R5 helps and using Schottky diodes for D1 and D2 eliminates the problem. Another option is to use a P-MOSFET for Q1, such as the BS250.Quote from: StillTrying on February 11, 2018, 04:08:36 pmGood idea. The downsides are: increased power dissipation and that the RGB LED will need both the anodes and cathodes of each element to be accessible, i.e. it can't be common anode/cathode.

author: darinsquared
author_rank: Contributor
timestamp: February 12, 2018, 04:20:18 pm
content: thank you everyone for the help. Once I get a few more of the components I will give this project a try. Just a note to the Admin, this is one of the best electronics forums. People do not get upset when a newbie that does electronics on a limited basis asks simple questions.

author: phil from seattle
author_rank: Super Contributor
timestamp: February 13, 2018, 02:05:28 am
content: Quote from: Hero999 on February 12, 2018, 10:14:18 amHmmm. Depends on what voltage you supply. Even with 5V and 220 ohm current limiting resistors I still get at least 8 mA through all 3 LEDs. The one driven by the transistor is slightly less - 8.15 mA vs 8.76 mA for the others. I doubt some one would see the difference if they were the same LEDs. Since they aren't and different different limiting resistor values would be used, it's complete a non-issue.

author: Zero999
author_rank: Super Contributor
timestamp: February 13, 2018, 09:07:04 am
content: Quote from: phil from seattle on February 13, 2018, 02:05:28 amI think you've misunderstood. The issue, with the schematic your posted, is not about the LEDs drawing different currents, but with the diode biasing Q1 on, causing the red LED to be on, when it shouldn't be.The voltage drop across R5 adds to D1's forward voltage, making the situation worse. Removing it helps, but D2 still won't turn off completely. If you don't have a Schottky diodes, adding another diode, in series with Q1's base will also solve the problem.This sort of thing isn't easy to simulate because real life components often differ from the models. If the D1's diode forward voltage is higher or Q1's VBElower, then more current will flow through the LED, than SPICE would predict. The temperature will also also make a difference. As Q1 heats up, its VBEwill fall, causing it to turn on more, with SPICE won't see, unless you have a program which includes accurate thermal models.

author: phil from seattle
author_rank: Super Contributor
timestamp: February 13, 2018, 05:52:57 pm
content: My sim shows the red LED drawing 0 (well, 12 uA) current when it is supposed to be off. Pretty sure that will not generate any light. What part of the sim is inaccurate?

author: hamster_nz
author_rank: Super Contributor
timestamp: February 13, 2018, 06:36:42 pm
content: Quote from: phil from seattle on February 13, 2018, 05:52:57 pmJust replace Q1 with a Darlington and everybody will be happy...

author: grifftech
author_rank: Frequent Contributor
timestamp: February 14, 2018, 03:39:55 pm
content: microcontroler

author: Zero999
author_rank: Super Contributor
timestamp: February 14, 2018, 07:18:14 pm
content: Quote from: phil from seattle on February 13, 2018, 05:52:57 pmIt will glow very dimly but won't be noticeble above the other LEDs,QuoteYou haven't posted the .asc file.The chances are my simulation isn't very accurate, because I didn't vary the VBEand the LTSpice doesn't account for the temperature rise of Q1. Did you?The only way to know how well it'll work, is to actually build it and even then it might not work the same with different components, even with the same part numbers. Isn't easier just to implement the fixes and be sure it'll work !00% of the time?Quote from: hamster_nz on February 13, 2018, 06:36:42 pmYes, that will work too.

author: phil from seattle
author_rank: Super Contributor
timestamp: February 14, 2018, 08:04:54 pm
content: Quote from: Hero999 on February 14, 2018, 07:18:14 pmLol. The light from 12 uA will be swamped by moonlight.And no, I didn't account for temperature but it's just not an issue.

author: Zero999
author_rank: Super Contributor
timestamp: February 15, 2018, 08:55:10 am
content: Quote from: phil from seattle on February 14, 2018, 08:04:54 pmBut if it's nearly 4mA, then it will be clearly visible!QuoteYou're wrong about temperature: it is an issue, because it affects device characteristics and different components dissipate amounts of power, causing the temperature between them to vary. The variation between components, is also critical and not taken into account by LTSpice!I can create plenty of schematics, which work very well in a simulator, but will perform poorly or simply won't work in real life.Here's another example. It's supposed to give two outputs: one the inverse of the input and one the same as the input, with a gain of 10. LTSpice will happily simulate it, showing a working circuit, but it will either fail to work, or perform really poorly in real life!https://www.eevblog.com/forum/chat/is-the-electronics-hobby-dead/msg988861/#msg988861

author: hamster_nz
author_rank: Super Contributor
timestamp: February 15, 2018, 09:54:07 am
content: Quote from: phil from seattle on February 14, 2018, 08:04:54 pmWell, I had a few minutes to kill, and spent most if it finding exactly the parts as the original schematic. Reality wins over simulation.The LED is dimly visible with the over-desk lights on, and clearly visible when the lights in the study nook are off (with ambient lighting from the lounge).Only when both Green and Blue both lit at the same time (i.e a jumper from +5 to the start of row 38) does the red LED turn off.(Picture is a bit dull because of the brightness of the Green LED)