Turn 1 LED off when other turns on and visa-versa?

This has nothing to do with software. I'm trying to figure out how to wire 2 LEDs on a breadboard so that when one LED is on, the other will turn off and visa-versa.

I got close, but one LED stayed slightly lit when the other turned on (going the other way worked fine).

For now I'm using software and an extra pin to handle it that way, but doesn't seem like there's a reason to handle this in code. If there's a hardware component that sent HIGH when LOW was input and LOW when HIGH, then that would do it. Can a transistor do that? Seems like it would have to be a component with three inputs, either way.

Thanks!

I got close, but one LED stayed slightly lit when the other turned on

Circuit? Sketch?

yea you can do it with 2 transistors

http://wild-bohemian.com/electronics/flasher.html

this is using a RC network for timing

but if your using an arduino its a pretty short sketch and a digital pin, like in the second example on that page (but its using a 555timer as a clock)

you can also use the same magic as is used in Charlyplexing http://www.instructables.com/id/Charlieplexing-LEDs--The-theory/step4/Finallya-Charlieplex-matrix/ Put the LEDs on the same wire but polarity reversed one led is sourcing current on one pin and getting current from the other.

DAvid

ArduinoM beat me to it, but also what about a not gate, that is what they are there for

What I got working was some variant of what ArduinoM was suggesting but I was trying to use the resistors as used in the examples and one of the LEDs was sort of lit when it should have been off.

Yeah, P18F4550 mentions the component I knew had to exist but couldn't think of the name. Just a NOT gate. I assume this is a 3 prong IC? Oh well, I don't have one in the kit I'm using and I have the spare output pin to spare so I'll just read the HIGH/LOW of one pin and set the other accordingly.

Thanks for the quick responses to the very, very green guy.

yea you can do it with 2 transistors

Umm, you can do it with 1 transistor...

That's probably easiest ;)

Mowcius

Benny-Nashville, do you have both ardiono pins set to output? they should be, if one is set to input and one aoutput that might be why one of the leds is dim when it should be off

Umm, you can do it with 1 transistor...

That's probably easiest

you could do it with a paperclip and a small box. But it will probably explode horribly then, McGuyver style and all the bad guys nearby will die.

@Mowcius, how do I wire it up with 1 transistor ?