Execute functions or SwitchCase via serial connection from 2nd arduino

Hi, I would like to communicate between 2 mega 2560's using the tx and rx serial connection. Is it possible to execute a function or SwitchCase on one of the megas?

This is what I was thinking.

One unit has a 5" display with a GUI and the other unit runs the program and equipment. The unit that runs the program would basically be a large SwitchCase statement. Can I send a number to it and have it excute that part of the SwitchCase statement?

So if the display sends #24 the other unit would execute case 24, is that possible?

Yes

...R

Great example of how to do that here

Thanks, I'm playing with it now but how do you keep 2 arduinos hooked up to the same computer?

Everytime I go to upload I have to complete disconnect the 2 arduinos and make sure only one is plugged into the computer. Then reconnect everything and test, its a very painful process.

On shows up as com6 the other as com10. I have 2 IDE's open, on points to on board on to the other, so when I hit upload shouldn't it work? Why do I have to disconnect other mega?

robsworld78:
so when I hit upload shouldn't it work? Why do I have to disconnect other mega?

You have to select the correct serial port.

...R

I do have it pointed to the correct port. It tries to upload, the board flashes then nothing and IDE says timed out.

I have not done what you are doing in a while, but I do recall having to disconnect the serial connection between the two boards in order to upload to either from my Mac.

Everytime I go to upload I have to complete disconnect the 2 arduinos and make sure only one is plugged into the computer. Then reconnect everything and test, its a very painful process.

Which pins are you using to connect the two Arduinos ? Not 0 and 1 by any chance ?

Yeah I'm using 0 and 1.

robsworld78:
Yeah I'm using 0 and 1.

Well so is the USB link to the PC. Why not use one of the other hardware serial ports on the megas for the communication between them ?

Which pins are you using to connect the two Arduinos ? Not 0 and 1 by any chance ?

That is not a show stopper, as I have used pins 0 and 1 on arduinos to communicate between them, using the serial monitor on both to monitor the serial activity. The problem appears to be getting a separate instance of the IDE working for each board. I use 1.0.5 and can do this. There have been recent reports that the latest IDE has issues with this.