Two arduinos, Same led

Hello everyone
As the title says, i'm trying to find a solution to turn on/off an LED using two different arduinos.
let's say we use Arduino1 to turn the LED on , then Arduino2 to turn off that same led.
Is it possible?
thank you in advance.

Yes, it is possible, with many components. Why do you want to use two different Arduinos?

I am working on a smart home project. i am using a lot of modules gsm, bluetooth , wifi ect..
these modules are connected to two different arduinos but need to control the same devices.
I was just testing with one led to find a solution.
Wich components are you talking about? thank you in advance

logic gates might work. Without knowing what or how it'd be used but if you wanted 1 led on when 1 Arduino has it on and not when both has it on, XOR gate should work.

There are a lot of solutions available for an led... but there are no similarities between lighting a led and sharing gsm data.

What you need is to create a network that can share data, instead of attempting to control the devices. I would look into mqtt and esp8266s for wireless coms.

deathmemorial:
I am working on a smart home project. i am using a lot of modules gsm, bluetooth , wifi ect..
these modules are connected to two different arduinos but need to control the same devices.
I was just testing with one led to find a solution.
Wich components are you talking about? thank you in advance

How will each arduino know if the LED is ON or OFF already?
How will arduinoA know if arduinoB hasn't already turn the LED ON?
You can't just get them each to toggle it ON/OFF unless you know its current state.
Tom... :slight_smile:

Easy if you use a bi-colour led with 2 leads, or two single-colour leds connected back-to-back.

Arduino A pin ---- series resistor ---- bi-colour led ---- Arduino B pin.

To switch the led on, Arduino A briefly changes the pin mode to INPUT, and reads the pin with digitalRead(). It then changes the mode back to OUTPUT and uses digitalWrite() to set the pin to the opposite of the value that was read (ie. HIGH for LOW and LOW for HIGH). To switch the led off, it writes the same value that was read. The two Arduinos must have a common ground, of course.

Is it possible for the Arduinos to message each other, even if via an intermediate device? If so, Arduino 'A' could control the LED directly and also take commands from Arduino 'B' about controlling the LED.

My arduinos are now sharing information via the I2C bus.
For the other modules wifi gsm bluetooth ect, i ended up using them all on the same arduino Mega ( wich has multiple Serial ports) . That fixed all my problems.

thank you all for the replies.

deathmemorial:
thank you all for the replies.

So what solution did you use for controlling your LED?

PaulRB:
So what solution did you use for controlling your LED?

Since i used all the modules (wifi, bluetooth, gsm) , and all the the devices to be controlled on the same arduino, i no longer have this issue. My problem was that i had each module on a different arduino uno (i didn't know the mega had multiple serial ports). So i used an OR gate. The problem with that is when i use a module to turn On a device, it's obviously impossible to turn it off with a different one. I tried to find a solution using logical gates as suggested by the reply above but i couldn't figure it out.
I fixed my problems for the project, but i still dunno how to control the same output using different arduinos.
I got 3 arduinos to communicate with each other via I2C bus. now i'll try toggling on/off the led now.

Having two devices who aren't communicating both trying to control the same piece of hardware is a huge design flaw. You'll end up in a situation where one wants it on and the other wants it off and the two just end up fighting it out flickering it on and off. It's like when the parents split up and refuse to communicate and can't agree on what rules to give the kid. It's just a mess.

deathmemorial:
Since i used all the modules (wifi, bluetooth, gsm) , and all the the devices to be controlled on the same arduino, i no longer have this issue.

So it was just an "X-Y" problem and we fell for it!

Hi,
What is your application?
Why do you need to have more than one source control a single LED?
What is it indicating?

Delta_G:
Having two devices who aren't communicating both trying to control the same piece of hardware is a huge design flaw. You'll end up in a situation where one wants it on and the other wants it off and the two just end up fighting it out flickering it on and off.

What have you done to prevent this situation.
What is your logic?

Thanks.. Tom.. :slight_smile:

TomGeorge:
Hi,
What is your application?
Why do you need to have more than one source control a single LED?

i'm building a smart house. I have multiple leds , fans , air conditionar , doors, garage , windows... ect + wireless modules , that are connected to two different arduinos.
I always use leds for tests before doing anything. Having two arduinos who aren't communicating trying to control the same device is indeed a design flaw. I was curious if it was possible though.