2 or 3 LED colors on a single digital pin

Oh shoot, I guess the bottom LED can't ever turn on. It would have to be turned the other way around. I clearly didn't think that all the way through. :thinking:

Yup and if you turn it round then you have to have a cathode and anode connected to the same pin, along with a ground.
I just tried to breadboard it flipped around and could not get it, but that doesn't mean much. If you have a different schematic I'm all about it.

@christop @LarryD
I saw some sense in the idea but it doesn't work with a common pin.
It does work with two different LEDs.

While very cool, it doesn't quite fit the needs of this project.

@chrisknightley @alto777 is this 2 LED circuit in 64 safe to use? I can sketch it up if the video isn't clear enough.

Yes, if I read it correctly.

If you never can see the output pin sinking or sourcing current beyond spec, it don’t much matter what’s hooked up to it or where the s
current leads.

But please do draw the schematic so we be sure.

a7

I don't think it's a problem, but it may not work if the LED Vf is low.
Because there is a current path from VCC to GND through the two LEDs.

Circuit of my understanding by the simulator (resistance value is sloppy)

This is the case if VCC exceeds the sum of both LEDs Vf.

1 Like

Agree @chrisknightley, lose that resistor, then the not operating LED is essential shorted out of the picture.

a7

When I originally ran it I used the pin and the 5V from the board, but the crossed LED stayed on a tiny bit, so I switched to the 3.3V for the constant power line.

I pulled R2 and it works fine of course. LED1 has twice the resistance of LED2 and it's still brighter. Looks like I need to step up R3 a bit more.

Right. Lose R2, put the 5 volts supply back in the picture if the output pin comes from a 5 volt powered chip.

Then tune brightness with the other resistors as you would any plain LED plus series resistor arrangement.

a7

1 Like

+1 to all things @alto777

I noticed that I don't need to post this. :upside_down_face:

Just about perfectly balanced now.

This is kind of cool from a logic perspective, like a cheap DDR-like clock signal but not quite because it's not really on the edges.

As you may know, you can turn off both by set the digital-pin as an INPUT (a.k.a. Hi-Z).

Sensitive to LED Vf and VCC voltage, there can always be a very small leakage current, but it works well in most cases.

A little math to file away :smiley:

I suspected this but was hesitant to until the circuit was reviewed. I guess I could have figured it out if I factored everything else out and saw it as a 4.7K resistor and a diode between the 5V pin and an input which is a safe configuration.

OK, now I gots to ask: where you picking up those 2K37 resistors? :expressionless:

White LEDs have a high enough Vf, shouldn't hear a peep outta them at hi-Z on the pin.

a7


Car audio resistors, I have a thing for non standard and vintage stuff. Saw the odd value and had to have them.
Turns out they are great for halving a 4.7k.
Got these on Amazon I think. I'll dig up the link.

Edit: I got them off ebay, there are loads of links now.

I feel that I can get it up to E96 series.
But I basically use it up to E24 series.

https://en.wikipedia.org/wiki/E_series_of_preferred_numbers

That did not work as expected:

Probably my fault.
Here's the code:

byte led_pin = 2;
void setup() {
}

void loop() {
  pinMode(led_pin, OUTPUT);
  digitalWrite(led_pin, HIGH);
  delay(500);
  digitalWrite(led_pin, LOW);
  delay(500);
  pinMode(led_pin, INPUT);
  delay(500);
  pinMode(led_pin, INPUT_PULLUP);
  delay(500);
}

Forgive the delays, they never make it past this kind of test.

BTW

Make yourself a logic probe/pluser using the same idea:

The extra 1N4148 diodes are to keep the logic LEDs OFF when the probe is not touched to a circuit point.

3 Likes