Need help wiring two Arduinos together directly with ins/outs

Hi all,
I’m new to the Arduino platform and also this forum. (Have been reading a lot tough but could’t find the answer I was looking for).
I am planning to control five very fast moving pneumatic cylinders, some with sensors in each end, some with analog sensor to read position. I want to connect two boards (Arduino mega) together directly with the Ins/Outs.

The reason for this is that I want to keep the code in the board doing the job as clean as possible. Then use the other board to read and log some of the signals at given times. The information will then be stored on SD-Card.
First I was thinking that I just could stack the boards with direct connections but that’s maybe not a good Idea? :~ Should I just put 1K resistors in between the in & outputs and then connect the ground and 5V between the boards with one power supply?

Unless there is some really complex math or logic going on the Arduino Mega should have more than enough time to control everything and log data on an SD breakout board.

You can break your sketch into different files to keep things neater. In a sketch I did that controlled video cameras and logged GPS, RealTime Clock, and temperature data for a high-altitude balloon I gave each section a "void module_setup()", "void module_loop()" and "void module_log(Print &logfile)". In setup() I called the setup function for each module:

  RTC_setup();
  GPS_setup();
  Cameras_setup();
  Thermometers_setup();

then in loop() I called the loop function for each module:

  GPS_loop();
  Cameras_loop();
  Thermometers_loop(LastLogTime, LOG_INTERVAL);
  RTC_loop();

The main module took care of the logging. To add the text for each module to the logfile I just call _log():

 ///////////////////////////////////////////////////////////////
  //  Log the RTC time
  RTC_log(logfile);
#if ECHO_TO_SERIAL
  RTC_log(Serial);
#endif //ECHO_TO_SERIAL

  ////////////////////////////////////////////////////////////////////
  //  Log temperatures
  logfile.print(", ");    
  Thermometers_log(logfile);
#if ECHO_TO_SERIAL
  Serial.print(", ");    
  Thermometers_log(Serial);
#endif //ECHO_TO_SERIAL

The reason for this is that I want to keep the code in the board doing the job as clean as possible.

This is a bit of a common mistake made by beginners.
Joining two arduino's together is very seldom the right answer.
But if you must then you can connect the pins directly together. If you are paranoid about the possibility that you might connect two pins together and make them both outputs AND set one high and the other low, then a 100R resistor will stop any damage.

Many thanks’ for your replies.

To be true, there is a bit more to it. Logging other stuff from can-bus and driving a couple of servos and I want to be sure that the program control the movements 100% flawlessly.

johnwasser:
Unless there is some really complex math or logic going on the Arduino Mega should have more than enough time to control everything and log data on an SD breakout board.

What makes me thinking about going this way is that the sequence of all the cylinders will sometimes take only about 250ms. I read somewhere that writing to sd can use up some time, up to 200ms, don’t know if this is true? Your suggestion seems to be a neat solution to keep the code clean tough.

Grumpy_Mike:
This is a bit of a common mistake made by beginners. Joining two arduino's together is very seldom the right answer.
But if you must, then a 100R resistor will stop any damage.

Then the topic may be useful for other newbes :slight_smile: Anyway, this really answers my question but I'm still thankful for all comments & thoughts regarding witch way to go.