I have some bicolour LEDs (3 pin, common cathode).
I currently have a simple circuit set up - with pin 2 and pin 3 supplying an output to both anodes of the LED and then GND hooked up to the anode.
One colour is dominant (as in, if I power both at once, then the other one doesn't even light up).
I wondered if it is something to do with GND so I swaped the cathode over to another pin and set that as OUTPUT LOW but the same thing occurs.
I thought you should be able to light both colours at once on a bicolour LED? Or do I need to alternate between the two at a high frequency instead? I have done it by alternating quickly but if I can just power both at once .. that would be much easier.
Do you have a current limit resistor on each anode? You're gonna damage the IO pins if you don't.
Connect the common cathode to Gnd, not to an IO pin. Limit the current on the 2 anode pins to 20mA.
(5V - Vf)/.02A = resistor value
I'm starting to wonder if maybe they are both on .. however the dominant colour is just so much brighter that I can't physically see the other one when they're both on 100% of the time. Alternating reduces both to 50% so maybe it allows the 'weaker' colour to visibly shine through? In which case, theres nothing to actually solve!
If you are using the same resistor value, try making the brighter LED a higher resistance to limit the current. The same resistance will result in different brightness for the same current because the LEDs are different materials (to get the colour).
The arduino output is 5V/20mA. So the resistor values I need are R=( V(supply)- V(forward) ) / I.
So for blue I get (5-3.8/20mA) = 60 Ohms and yellow is 135 Ohms. Is that correct? They seem quite low.
I'm actually going to be using one of these chips to drive the LEDs in the final thing (https://www.adafruit.com/datasheets/tlc5947.pdf) which looks like it has different output values in which case those resistor values will definitely be wrong. However the description of this chip says that you do not need to use current limiting resistors due to an inbuilt one..
"Outputs from these boards are constant-current and open drain. You can drive multiple LEDs in series. One resistor is used to set the current for each of the outputs, the constant current means that the LED brightness doesn't vary if the power supply dips."
So maybe I should add an extra resistor to the brighter colour and leave the other one connected directly to the chip?
It doesn't have to me 20mA. I think the spec is up to 20mA. It would be better to look at the brightness output curve for the LED and pick comparable points for both colors, then look up the current for that brightness, then work out the resistance you need for that current.
More to the point, use the maximum current as defining a minimum resistance and just work upward with resistor values on the brighter one until it looks right.
This is not something you do by theory and calculation.
I usually determine the color of a multi-colored LED by the position and relative brightness of the emitters (blue usually looks unique, but red/amber/yellow/green/ are often indistinguishable).Because of this, color-based annunciators should not be too bright - just less than squinting when the size is that of an outstretched hand at arm's length.
Better yet - use yellow/green/blue LEDs instead of red/yellow/green.
Just use separate LEDS to cater for those that are colour blind I have a colleague who is (partial ?) colour blind. He can't e.g. see the difference between red and green and therefore hates equipment with one LED displaying two different colours to indicate a status.
Grumpy_Mike:
The scientific name for people who can't tell the difference between red and green is cyclist.
That is at your side of the world; here they are called taxi drivers They also think that the emergency lanes were specially made for them (and there is more).
If the LEDs will be driven with tlc5490 eventually, there will be 4096 levels of PWM brightness control for mixing colors.
You could play with 255 levels for now by using
analogWrite (pinX, value);
with pinX being pins 3,5,6,9,10, or 11 and
value from 0 to 255. 0 = full off, 255 = full on