connecting 2 mega 2560's together

Hello all, have been tring to find information to connect 2 mega's 2560 together to expand the digital pins, can only find how to connect 2 unos, can some one explain please. thanks in advance.

If you are talking about a serial connection, it is the same as connecting 2 Unos except you use 1 of the extra hardware serial ports on each 2560 in place of software serial. Then, for example, wire Serial1 TX on one 2560 to Serial1 RX of the other and visa-versa.

If not Serial, we need to know what method that you want to use.

jphere:
to expand the digital pins

you could use I2C portexpanders that you can control directly.

Exp1
Pexp1.png

Exp2
pexp2.png

Exp3
pexp3.png

Thanks for the reply guys. I am using the mega's to control led lights and gauges for my overhead panel of my flight sim. I have used all the digital connections on the one mega and am hoping to use the 2nd mega for more connections for more gauges. so if I understand this, I can just connect RX and TX with common GRD same as the uno's? Do I also need to connect a USB to the PC. If someone has a image of the correct connection would be great. Thanks

Here you go.

Do I also need to connect a USB to the PC.

How are the Megas powered if not by USB? All the 2 Megas need to communicate between them is power and proper software on each. The Serial to the PC is not needed unless you want to see debug information or program output.

:slight_smile: Thanks Ground, I'll give that a shot.

Once you get the basic communication working, you will want to send packets of data back and forth between the Megas, The serial input basics thread shows how to send and receive serial data in a reliable and non blocking fashion.

Connecting Megas together for the sole purpose of getting more I/O pins is a beginner's mistake.
Take Whandall's advice (post#2).
Leo..

I answered the question as asked even though I agree with Whandall and Wawa. It would be better to use I2C expanders and/or shift registers to increase the number of usable pins.

And adressable LEDs to expand the number of LEDs.