Search code examples
c#winformsautomationarduinoarduino-uno

Arduino UNO mouse emulator


I have an Arduino UNO, and I'm trying to write a program in C# using VS WinForms that will send a signal to the Arduino UNO with the coordinates where the mouse cursor needs to be moved, and the Arduino UNO will emulate a mouse in response. How to do it? Which libraries should I use? Where can I get information?


Solution

  • It's theoretical possible with an arduino, but you'll need to use the ATmega16U2 microcontroller on that board that controls the usb, program upload and the usb-serial connection. You would have to re-flash this controller with a bare-bone software - nothing from the Arduino Studio IDE. The USB could be re-programmed to act as HID (human input device) with an additional endpoint for communication. The Arduino would then be recognized as mouse if plugged in via USB. But the Arduino USB firmware is gone then, so the device cannot be used as Arduino any longer (ok, you could later re-flash the original firmware).

    But it's complicated and the board is not a good hardware for this task. You should rather use a much simpler board with an USB-capable microcontroller like the ATMega32U4 or similar.