Device to power either a red LED or a green LED
You mention an IO pin; this is how you could do it with one IO pin if you are using a microcontroller (assuming one that uses 5V logic):



simulate this circuit &ndash; Schematic created using CircuitLab
When the IO pin is 5V, D2 will light up; when the IO pin is 0V, D1 will light up.
Note that you will have to calculate the actual resistor values; different types and colours of LED require different resistors. There are plenty of examples about that show how to calculate these values.
Also, make sure you don't sink/source too much current; the maximum current an IO pin can handle varies from microcontroller to microcontroller.