Using 2 Arduinos

Can I have one Arduino communicate with another by setting one I/O pin as an Output and the other as an Input on the second Arduino? I know on the same Arduino this could short out the pin but would it work if it was two separate ones?

Hi

Yes you can. If you digitalWrite(TXpin, high) on one Arduino a sketch on the 2nd Arduino can see the state of the input pin with a digitalRead(RXpin). That would give you simple one-way communication. I've had a couple of projects where a 2nd microcontroller on a shield knew to act when a trigger line was held high, just like this.

If you want to send data, you could set up a serial link between them too.

schoolsterz123: I know on the same Arduino this could short out the pin but would it work if it was two separate ones?

There would be no issue with shorting out an Arduino pulsing a pin high and reading it from another pin, aside from the obvious "why would you?" question.

Cheers ! Geoff

Yes you can.

I know on the same Arduino this could short out the pin but would it work if it was two separate ones?

Same or two different Arduinos you can still "short" out a pin. It's up to you to get the handshaking and IO right.

There are about a 1000 ways you can have two processors talk to each other, what information do you need to exchange? One way or both ways? Fast or slow?


Rob

If your using a 9V external power supply does that effect the output voltage of the I/O pins or only the VIN pin?

Hi

VIN and the 2.1mm jack both connect to the microcontroller via the voltage regulator, so if you applied 9V to either of those the pin voltage should still approximate 5V.

Cheers ! Geoff

schoolsterz123: Can I have one Arduino communicate with another by setting one I/O pin as an Output and the other as an Input on the second Arduino? I know on the same Arduino this could short out the pin ...

No it wouldn't. A pin set as input has a resistor inside the chip so you'll be perfectly OK.

You only get a short if both pins are set as output and you program one HIGH and the other LOW.

schoolsterz123: would it work if it was two separate ones?

The situation is exactly the same if the two pins are on different Arduinos.

I believe you would need to connect the grounds of the two Arduinos if you are connecting the pins directly, or use an optocoupler or similar if the two are electrically isolated.

If you’re only communicating a simple “GO” kind of signal a digital pin is fine. If you need to send more complex info you could connect the serial Tx pin of the “master” to the serial Rx pin of the “slave” (provided they are both the same voltage levels - e.g. don’t connect the Tx of a Uno to the Rx of a Due).

Pete

Yes you can easily wire a digital output pin from one arduino to another arduino. You will have to also have a ground wire run between the two boards no matter how each board is wired. A good safety item would be to wire a series 1K ohm resistor that wires from one digital output pin to the other's digital input pin, this will protect both boards if you ever made a mistake and had both pins set as output pin and at opposite states.

Lefty