Two Arduinos connected through digital pins?

Hi all, This may be answered elsewhere but here it goes anyhow. I have two Arduino micro controllers in my robot project. One is for controlling motors and servos, the other will be used for reading the sensors in the robot.

I mainly did this so that I could read the output of the controllers and/or write to controllers at the same time if I wanted to.

One of the tasks that needs to be handled for the robot is driving around the house. The electrical system has one common ground bus for all electronics in the robot.

so my idea is to be reading from the distance sensor while driving and if we get within a certain distaince, say 10 CM, I want to stop. however I foresee the possible need to emergency stop. So would it be possible to safely connect one of the digital pins on the Sensor reading controller (an Arduino Micro) and have it write to that pin, then for each iteration of a loop on the motor controlling Arduino (A mega 2560 R3) read the output of the sensor Arduino on one of the digital pins and call a sudden halt?

Note that I am not asking for coding advice here, but I just want to make sure that I will not fry the Micro controllers or PC they are connected to via USB cable.

Essentially the goal is to cut down on the latency of communications between the sensor controller and the motor controller. If it's not possible electrically then I will just not do it.

thanks, Brian

As long as an output pin on one Arduino is connected to an input pin on the other, everything will be OK.

Connecting two outputs together is a problem because if one writes high and the other writes low, excessive current will flow.

(It's also OK to connect two inputs together.)

ok thank you! just what I needed to know

Hi, brihno

The safe and easy way to pass information between two Arduinos is by I2C. Simple 2 wire + ground connection and information flow is practically instantaneous. And the sketch function for reading/writing between them is simple too.

-geeq

Can I connect 3 pins as output from inputs on another Arduino . Planed to perform particular word to transmit when the particular pin was High...

Would I face any problems.