What happens if command a DigitalWrite into another Output port?

Hi!!

I'm working in a project when Sometime maybe a port may write a HIGH value into another port that is outpus as well but this another port in case may be 0V.

Example:
...
imagine a scenary where 2 pins can turn the same led on.
In case of the port 10 is 0v, could I just send 5V to this port trough another port?

Why do you need 2 pins to control one LED ?
Have you got any code and/or a circuit that illustrates this need as it sounds very unusual ?

Hi.

Its because one button has various fucntions and one of them are turn a landing gear light on.

But sometimes or in a emergency, just one button is needed turn a light on.

Did I illustrate my case?

cabecinhas:
Hi.

Its because one button has various fucntions and one of them are turn a landing gear light on.

But sometimes or in a emergency, just one button is needed turn a light on.

Did I illustrate my case?

That doesn't mean you have to do what you said in the first post though. something like the below would surely do the trick?

void setup(){
pinMode(3, INPUT);  // a switch
pinMode(4, INPUT);  // another switch
pinMode(5, OUTPUT);  //the led
}

void loop(){
if (digitalRead(3) == HIGH || digitalRead(4) == HIGH {
   digitalWrite(5, HIGH);
}
}

Hi

Seems just like my project. but sometime the pin 3 may be 0 and pin 4 may be 5v;

What if pin 3 is turning port 5 off (0v) and if the pin 4 turning the port 5 on at the same time?

That will burn the arduino port, I think, right?

void setup(){
pinMode(3, INPUT); // a switch
pinMode(4, INPUT); // another switch
pinMode(5, OUTPUT); //the led
}

void loop(){
if (digitalRead(3) == HIGH || digitalRead(4) == HIGH {
digitalWrite(5, HIGH);
}
}

Santa Claus’s imaginary north pole house burns down while he has his shirts off, if you execute that imaginary scenario and he will be very much pissed.

The whole point of programming is to take multiple inputs into consideration in deciding what the output should be. If you have two or two million buttons, you decide how the combination of on/off states of these buttons determine the on/off state of the LED, not the way you described.

But they don't happen at the same time.

If one thing switches a pin on, and another switches it off, whichever happens later in time will be the current status.

ok… You’re right.

:slight_smile:

Thank you all