Connecting 1 Arduino to 2 computers

Hi!

My project includes a laptop, a desktop computer and one Arduino. My laptop gathers and processes data that needs to be sent to the Arduino which then needs to simulate mouse movement on the desktop computer accordingly to the data received. What would be the best way to connect all of this together, and which components would be required?

So far I've been using a Pro Micro for a similar project where only a single computer was required. I was running a C++ program which gathered data and sent it over the COM port to Pro Micro which then simulated mouse movement on the same PC simultaneously.

Really scratching my head about this new project though. I've been searching for an Arduino with 2 micro USB ports and a mouse emulation capability but nothing comes up. If I buy a Leonardo can I send data to it over the ethernet port and have the USB cable connected to my desktop?

Help is really appreciated!

An Arduino Due has two USB ports. It can do this.

It is not a good idea to plug two different computers in at the same time. Their grounds may be different and there may be a lot of current flowing in the ground wire of the USB cable as a result. If you can run the laptop on its battery while the two are connected like this it will be much safer.

Couple of other things you could investigate :

  1. Software serial- having multiple con ports on a UNO/nano etc.
  2. Opto isolators and isolated coms ( google) ; to remove any possible grounding issues

MorganS:
An Arduino Due has two USB ports. It can do this.

It is not a good idea to plug two different computers in at the same time. Their grounds may be different and there may be a lot of current flowing in the ground wire of the USB cable as a result. If you can run the laptop on its battery while the two are connected like this it will be much safer.

I bought an Arduino Due but I can't get it to work like this.

I'm trying to simulate mouse movement through native port on my PC and it works only if the programming port is not connected to my laptop. As soon as I connect the programming port to my laptop, the mouse stops moving on my PC.

Have you got any code examples that could help me?

Have you got any code that would help us diagnose the problem you're having?

There is no need for a DUE. You could connect the laptop to the Serial1 pins on a ProMicro using a USB-TTL cable and that leaves the normal USB port free for connection to the PC as a HID device.

...R