0
\$\begingroup\$

I have a bi color Red-Green LED with 3 legs (Common Anode).

How can I drive the LED using a single pin from microcontroller (ATtiny45) without using any external logic gates?

I only need red or green at a time mutually exclusive. Combined color/Off state not needed. They are just for status indicators and need to be as bright as possible.

Any schematic using discrete components would be helpful.

\$\endgroup\$
  • 1
    \$\begingroup\$ This could be helpful: dangerousprototypes.com/blog/2011/10/24/… \$\endgroup\$ – Swanand Jan 2 '17 at 3:31
  • 1
    \$\begingroup\$ Given that any solution using transistors (one or several) is probably going to take up more space than simply jumping to something like the ATTiny44 (6 extra pins), why not use the larger MCU? Alternatively, go for a bicolour 2-pin LED and use the solution @Swanand posted a link to. \$\endgroup\$ – Tom Carpenter Jan 2 '17 at 10:32
5
\$\begingroup\$

Given the Forward voltage differences between Red and Green LEDS allows for a very simple circuit and using your Common Anode configuration.

enter image description here

schematic

simulate this circuit – Schematic created using CircuitLab

You can set your LED current to any value you want, but there will always be a variation between Red - Green current that is unavoidable.

How well this works for you will depend on how the Red/Grn LEDs are built. For example with this Common Anode LED the difference between the Grn/Red VF is as shown below:

enter image description here

With this bi-color at any current below 30 mA through the Red LED, the Green LEED will be essentially off (uA). If you are using discrete LED's this will work for almost all devices. but note that some newer SMD bi-color LEDs use a mixed technology and the VF's are much closer together, for those devices this drive architecture may not work.

Update: after doing some tests with various LEDs, here's a way to handle diodes with no difference in Vf. In addition this can be used if you are using diode currents (typically <20 mA) that can be handled directly by a microprocessor pin.

schematic

simulate this circuit

\$\endgroup\$
  • 1
    \$\begingroup\$ This won't work well. There will still be some conduction through the green LED - even a couple of mA is enough to produce a quite visible amount of light. \$\endgroup\$ – Tom Carpenter Jan 2 '17 at 10:24
  • \$\begingroup\$ @TomCarpenter. Within in reasonable limits it works well. And since the LEDS are typically not separate (ie same visible channel) you see only a single color. \$\endgroup\$ – Jack Creasey Jan 2 '17 at 16:32
4
\$\begingroup\$

This breaks out of your parameters slightly, but I feel like it is by far the simplest solution.

If you use discrete LEDs, or LEDs with independently accessible anodes and cathodes, you can use this circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

HI:          D1 On
LO:          D2 On
HiZ:         Off
Toggle fast: D1 & D2 on

Note: This will only work with a pair of LEDs whose Vf is greater than 3.3V! Even so, the LEDs may still very slightly glow all the time. You just need to evaluate this tradeoff and whether it's worth it for the low part count.

\$\endgroup\$
  • \$\begingroup\$ Good one. OP should share the LED datasheet for evaluation. \$\endgroup\$ – Umar Jan 2 '17 at 4:06
  • \$\begingroup\$ @Umar, they said "common anode" so their current device won't work for this. \$\endgroup\$ – The Photon Jan 2 '17 at 4:09
  • \$\begingroup\$ But not a common anode bi-color pair. \$\endgroup\$ – Jack Creasey Jan 2 '17 at 4:12
  • \$\begingroup\$ @ThePhoton Yes you are right too. The bicolor LEDs will mostly be common anode type or common cathode type, including the OP ones. Hence, above solution is for discrete LEDs for best \$\endgroup\$ – Umar Jan 2 '17 at 5:11
  • \$\begingroup\$ LOL you beat me to this one. \$\endgroup\$ – Ryan Griggs Jan 3 '17 at 3:41
4
\$\begingroup\$

Wouldn't this simple circuit below work well for the required 2 color states only?

schematic

simulate this circuit – Schematic created using CircuitLab

ATtiny datasheet shows it can drive low 10 mA to 0.2V, so take advantage of that.

  • Logic high = D2 turns on

  • Logic low = D1 turns on

  • Tristate the output = D1 is teeny tiny bit on, D2 is on

So pick the color for D2 which will be on whenever your processor is still in reset.

Also, if you want different LED currents then short Rlim and put different resistors on the LED cathodes.

For Q1, you can use a digital transistor (integrated resistors) or you can use an N-channel MOSFET without a gate resistor.

\$\endgroup\$
  • \$\begingroup\$ Pstron. It works but you do have to be mindful of VCE(sat) for the BJT transistor....though this configuration would also work for an N-Channel FET and you would save a resistor \$\endgroup\$ – Jack Creasey Jan 3 '17 at 21:44
1
\$\begingroup\$

This is not the simplest solution, but if the other methods above don't work as expected, try the following, since the above ones (as I can see) seem to only work on certain conditions.

enter image description here

You can't use BJTs instead of MOSFETs in this circuit because the LED can go through the bases and they can be both unintentionally turned on at the same time.

If you don't have MOSFETs, use this circuit:

enter image description here

This circuit works by pulling the NPN down via the input tag to disable the green and at the same time powering the red. The diode is to prevent current going through the base and powering the red LED.

\$\endgroup\$

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.