Digital I/O between two arduinos.

Hello to everyone.
I have a working project that uses 6 switches (digital Inputs) to select the state of an rgb led. The inputs use Internal pullUp resistors and the switches put the input to ground. Its working.

Now I need to use another Arduino (arduino 2) to “press the switch” on Arduino 1. Not really press the switch, just put the input to ground I think.

Both Arduinos will be powered by different power sources, wiring Grounds together, Im wondering if my scheme (attached) would work…

When the Output on Arduino 2 is Low, On Arduino 1 I will get the same effect as pressing the switch, but Im not sure if its safe to put that output to 5V and send that to the Arduino 1.
If this works… will also work with a shift register? I need 6 switches.

I will be using standalone arduino, not the board.

Thanks in advance.

Ardu.png

but Im not sure if its safe to put that output to 5V and send that to the Arduino 1.

It is safe.

will also work with a shift register?

You mean putting the output of one Arduino to the input of a shift register. Yes that will work, but you need the right sort of shift register. You need the parallel in serial out type, not the serial in parallel out type.

You should never try to short an output pin by a switch, this will kill the output pin. But you can use Wired AND, by adding a diode to the output pin, with its kathode towards the output, and its anode towards the input pin. With such protection the output pin can only sink current, i.e. signal a LOW, while the input only can be HIGH if no button is pressed and all outputs are HIGH.