Share variable between 2 Arduino Mega cards?

I have a project using 2 Arduino Mega 2560 cards connected to the PC using 2 USB ports (COM 8 / COM 9)

One Mega card uses a switch to change a little code in that card using a string variable "LCDMode".

I would like that variable to be passed to the other Mega card so when the switch is toggled in the first card, the 2nd card sees the change.

Is this possible without connecting the 2 cards using the I2C connection? Can it be done just over USB communication?

Thanks for the help!
Mike

Why not just a single wire? High is one mode, Low is another. 2nd card can just read it.

Mega has 4 hardware serial ports. Have them communicate over one of the ports.

Thank you for the reply. If that is my only option, then I'll have to go with it.

The reason I was trying to send it some other method is the Mega cards are in separate boxes and some distance away from each other. So I was trying to minimize the wiring and just send the variable across the USB somehow.

Mike

Do I have this right?

Both Megas are plugged into one computer via USB cables? If that is the case then no, what you want to do can't happen without help from the PC. The two Megas aren't connected to one another in any way that allows them to communicate directly with one another.

It would however be trivially simple to write a sketch in Processing or a program in Python that could be open on the PC. In that case the program could act as a link between the two, receiving Serial data over USB and then communicating that data via USB to the other Arduino.

Maybe wireless ?

For example: Arduino RF link using 433MHz Transmitter / Receiver modules