Go Down

Topic: connecting 2 mega 2560's together (Read 246 times) previous topic - next topic

jphere

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.

groundFungus

#1
Mar 25, 2019, 08:47 pm Last Edit: Mar 25, 2019, 10:49 pm by groundFungus
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.

Whandall

#2
Mar 25, 2019, 10:18 pm Last Edit: Mar 25, 2019, 10:20 pm by Whandall
to expand the digital pins
you could use I2C portexpanders that you can control directly.

Exp1


Exp2


Exp3
Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. (D.Adams)

jphere

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

groundFungus

#4
Mar 26, 2019, 03:38 pm Last Edit: Mar 26, 2019, 03:42 pm by groundFungus
Here you go.



Quote
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.

jphere

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

groundFungus

 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.

Wawa

#7
Mar 27, 2019, 01:19 am Last Edit: Mar 27, 2019, 01:20 am by Wawa
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..

groundFungus

#8
Mar 27, 2019, 01:36 am Last Edit: Mar 27, 2019, 01:36 am by groundFungus
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.

MorganS

And adressable LEDs to expand the number of LEDs.
"The problem is in the code you didn't post."

Go Up