# 2 leds in the same time

Hi everyone I am trying to turn on 2 leds in the same time like it's the mirror of the first one. thank you

Yes.

You know the score by now, you have been told often enough.
Post your code and say how they are wired up.

What's "mirror" mean here? To me a mirror would be like a reversal maybe? The opposite? So when LED1 is on, LED2 must be off, and 2 is on when 1 is off?

But hey as G_M says, help us to help you by giving us something to go on. Nobody will write your code, but we'll help you sort stuff that you tried but are having trouble with.

PORTD = PORTD & 0b11110011; // 2 LEDs off PORTD = PORTD | 0b00001100; // 2 LEDs on

JimboZA:
What’s “mirror” mean here? To me a mirror would be like a reversal maybe? The opposite? So when LED1 is on, LED2 must be off, and 2 is on when 1 is off?

But hey as G_M says, help us to help you by giving us something to go on. Nobody will write your code, but we’ll help you sort stuff that you tried but are having trouble with.

Yeah so when one is on the second is off
thank you

``````if (LED1 == HIGH) digitalWrite(LED2, LOW);
if (LED1 == LOW) digitalWrite(LED2, HIGH);
``````

``````if (LED1 == HIGH) digitalWrite(LED2, LOW);
if (LED1 == LOW) digitalWrite(LED2, HIGH);
``````

Nah - too confusing "LED1" appears to be a state, but "LED2" is a pin number.

Ah crap, sorry...

``````if (digitalRead(LED1) == HIGH) digitalWrite(LED2, LOW);
if (digitalRead(LED1) == LOW) digitalWrite(LED2, HIGH);
``````

Jhjh:

JimboZA: What's "mirror" mean here? To me a mirror would be like a reversal maybe? The opposite? So when LED1 is on, LED2 must be off, and 2 is on when 1 is off?

But hey as G_M says, help us to help you by giving us something to go on. Nobody will write your code, but we'll help you sort stuff that you tried but are having trouble with.

Yeah so when one is on the second is off thank you

Ah, that's easy, its a hardware problem:

Connect one LED and its series resistor between the pin and GND, connect the other and its series resistor between the pin and Vcc.

MarkT: Ah, that's easy, its a hardware problem:

Connect one LED and its series resistor between the pin and GND, connect the other and its series resistor between the pin and Vcc.

.... making sure the flat side of the LED faces the right way :P