My take is slightly different from that of suicidalacorn's... I think that with either 01 or 10 and therefore activating the R xor G LEDs, there's enough of a "short" across the AND gate for it to read both its inputs as 1's.
(Which is what suicidalacorn was saying, on second thoughts, now that I see his annotated pic....)
So now do a proper one, showing each LED and the series resistor connected to each LED along with values.
In other words a schematic that people can understand.
What are you trying to achieve? You mentioned a traffic light. Do you mean that you only want one of the LED's on at a time or do you want the Yellow to light up when the Red AND Green are on?
You may want to use inverters as well if you want only one on at a time.
I remmember once trying to dirrectly drive a seven segment display with my Arduino and the segments were really dim I checked and found that I forgot to put
What does it do?
The LEDs can all be driven thru the IO pins shown:
D1 = 1, D0 = 0 turns on LED1
D1 = 0, D0 = 1 turns on LED2
D1 = D0 turns LED1 & LED2 off
same for 3,4 5,6 7,8
What's the AND gate do that couldn't be done with another IO pin instead?
pranoy:
this is a fair ckt dgm with only one yellow LED
Regarding that diagram, the pins that go through a resistor to the LEDs should not be connected to the input of the AND gate, this should be connected directly to the arduino. I suspect that it is this that is causing a problem because the current flowing through that resistor is holding the input to the AND high and thus keeping the yellow on, which still needs its own series resistor.