Switching between colours on red/green LED (with 2 leads) - Page 1
Forum section: electronics / beginners

author: tomoram
author_rank: Contributor
timestamp: August 13, 2020, 11:58:22 am
content: Hi,I'm new here and this is my first postI recently ended up with (i.e. accidentally ordered the wrong part) a few red/green bi-colour LEDs (L-57EGW) which only have two leads (the colour is switched by changing the direction of current flow). As a little exercise I decided to come up with a circuit to switching between the colours and I came up with the attached circuit (note the single diode is represented by 2 diodes in the dashed box):It works as expected (i.e. press SW1 and the LED changes colour) but I'm unhappy with the power consumption (~70mA) - i.e. I'm convinced that a circuit do simply like an LED should be ~30mA. This extra current is being drawn because there's always a path to ground through one of the 100ohm resistors.One thing I've tried is increasing the resistance of R1 & R2, and while this lowers the power consumption of the circuit, it also lowers the current through the LEDs, so they get dimmer.So I have 2 questions:1. Is there a methodical way/approach to optimise a circuit (such as the one above) so that I you get a desired current (say 25mA) through the LED but minimise the overall power consumption of the circuit.2. What might be some better circuits (can use any other components - only constraints being the bi-colour LED and 5V)I look forward to some interesting responses

author: magic
author_rank: Super Contributor
timestamp: August 13, 2020, 12:19:12 pm
content: H bridge.And it could be built with just a single DPDT switch.

author: Ian.M
author_rank: Super Contributor
timestamp: August 13, 2020, 01:38:55 pm
content: If you *must* use discretes, I've got a bastardized combo of 3/4 of a H-bridge and two current sources for you. The current sources control each LED's current so their Vf is largely irreverent. It uses seven resistors, three transistors and a dual Schottky diode. LTspice sim attached.

author: tomoram
author_rank: Contributor
timestamp: August 13, 2020, 01:55:26 pm
content: Thanks magic!I was not aware of H-Bridge (mostly very new to electronics) but looked it up and it makes perfect sense. It was actually an idea I had come up with and considered but it seemed like too many transistorsI'm assuming there might be an IC that might make more sense than 4 transistors?The DPDT switch makes perfect sense but I was just using the switch to test the idea, I was actually trying to think of something that could be driven by a Raspberry Pi.

author: tomoram
author_rank: Contributor
timestamp: August 13, 2020, 01:58:04 pm
content: Quote from: Ian.M on August 13, 2020, 01:38:55 pmThanks! I'll try and wrap my head around the LTspice sim!I definitely was trying to think of possibilities with discretes, but also curious as to what ICs might be available?

author: Ian.M
author_rank: Super Contributor
timestamp: August 13, 2020, 02:27:56 pm
content: For a 'Pi-able' solution consider the74LVC2T45dual level-shifting buffer.It can easily drive 25mA through the LED. Connect the LED + a series resistor to set the current between A1 and A2, with VccA to +5V, ground the DIR pin, feed VccB +3.3V, and drive its B1, B2 pins from Pi GPIOs. If both B pins are the same level, the LED will be off, and each opposite level combo lights one colour.

author: tomoram
author_rank: Contributor
timestamp: August 13, 2020, 03:59:30 pm
content: Quote from: Ian.M on August 13, 2020, 02:27:56 pmThanks great info - thanks!

author: tomoram
author_rank: Contributor
timestamp: August 14, 2020, 07:23:50 am
content: Quote from: magic on August 13, 2020, 12:19:12 pmI've been trying to build a H bridge version but I'm struggling to get the same behaviour (i.e. toggle between the colour with a push button).I've attached a couple of images, one showing what I'm stuck with and one showing one bad solution I came up with using resistors and a transistor (good power consumption until you press the button). Any suggestions on what I could use here (using discrete components)?

author: tomoram
author_rank: Contributor
timestamp: August 14, 2020, 07:43:53 am
content: I've also been toying with this op amp circuit. Is this sensible/a done thing?

author: magic
author_rank: Super Contributor
timestamp: August 14, 2020, 08:22:12 am
content: These could be comparators instead. Or simply logic inverters, one driven by the button and the other driven by the former's output. Something like 74HC14 or 74LVC2G14 for a small SMD package with only two gates.

author: desy2820
author_rank: Contributor
timestamp: August 14, 2020, 11:57:02 pm
content: Tomoram,You may be able to drive the LED directly from the Rasberry, using two GPIO pins and a resistor. Connect the LED between the GPIO pins, with a resistor in series. Pin-->Resistor-->LED-->other pin. In your code, make one connected pin high and the other pin low. This should light the LED.To change colors, reverse the pin states. Make the pin High that was Low and vice-versa. To turn off the LED, make both pins the same state, either both high or both low. Blinking can be done the same way.IMPORTANT NOTES:I'm an electronics beginner, like yourself. I have no idea how to code the Raspberry.The resistor is very important! Don't leave it out. I haven't done a lot of research, but I think a good starting point is 330 ohms. It can be higher, but will reduce the brightness of the LED. 3v3 volts / 1o mA = 330 ohms. You may also need to specify a high drive level in your code, again, not entirely sure.This relates to the amount of current each pin can supply, as well as the limits for the whole chip. A quick search indicates a max of 16 mA per pin, with 50 mA overall for the entire chip. At 10 mA (0.01 amperes) each, you should be able to safely drive 4 of the LEDs.

author: rstofer
author_rank: Super Contributor
timestamp: August 15, 2020, 03:44:26 pm
content: Quote from: desy2820 on August 14, 2020, 11:57:02 pmI think the 10 mA current calculation is way off. The diode has a forward voltage drop, perhaps on the order ot 2V (find a datasheet or measure with a multimeter. Take the lowest forward voltage (red versus green) and call it Vf.Then, (3.3 - Vf) / 0.01 will be the resistance value for 10 mA on the diode with the lowest Vf. For Vf = 2V the numbers are (3.3 - 2) / 0.01 => 130 Ohms. I would probably use 150 Ohms.Here is a typical datasheet and on page 4, the Vf of the Red led is, in fact, 2Vhttp://www.farnell.com/datasheets/1756451.pdfThe 150 Ohm resistor only allows 8 mA (green) or 8.6 mA (red) to flow and that assumes the pins pull to the rails (Gnd or 3.3V) when loaded.

author: RJSV
author_rank: Super Contributor
timestamp: August 16, 2020, 01:58:36 am
content: If you want to individually tailor the LED color brightness, just use a diode - resistor, for each direction (color). Will be ok as long as enough overhead voltage, so maybe diode with 100 ohms for that situation, for one LED, and tailor the other with 150 ohms, for instance.