I want to control a red and green led with one pin. When the pin is high I would like to light a red led and when its low I would like to light a green led.
Hope that makes sense!
Yes it does.
Connect like this:
+5v to R1 (330 ohm) to green LED anode.
Green LED cathode to red LED anode and to Pin.
Red LED cathode to R2 (330 ohm) to ground.
And ... that's it!
You can even turn it YELLOW (green & red together) by changing the pin to an INPUT (high-impedance) and the current will flow thru both LEDS (which will be a little dimmer than when they are green or red).
I am using this 3 color scheme for my model railroad signals, only I use HIGH for green, LOW for red and INPUT for yellow.
I hope it helps.