0

I have an Arduino Mega 2560 connected to a Windows 8 laptop. I want to program it to send keystrokes to the attached computer (when a pin's digital read goes from HIGH to LOW.)

The trouble is, I cannot find any way to program my Arduino Mega to send keystrokes.

The supposedly "core" Keyboard and Mouse libraries only support 32u4 boards, and other libraries that give the Arduino keystroke functionality are out of sight. When I googled the issue, I found no question or explanation of how to send keystrokes on the Arduino Mega. When I searched further, I thought the V-USB library would be a potential workaround, but the library throws numerous errors when imported into an Arduino sketch (even on the 1.0.0 IDE it was designed for.)

After hours of searching, two final workarounds seem to have popped up:

  1. Some method to run a Python code to send keystrokes to the PC, and then connect the Arduino code to Python. (I don't know Python...)
  2. Use some program called Gobetwino, which runs between the Arduino and PC, to convert Serial commands into keystrokes somehow. (Pressing and releasing a key can't be simulated very well by repeatedly sending Serial commands, I think.)

Both are very unideal, very tedious, and are equally likely to just not work. I have spent hours on this.

Does anyone have any suggestions to get me out of this hell? Libraries, workarounds, anything?

(Feel free to PM me questions for clarification.)

Kaljune
  • 1
  • 1
  • 1
  • 1

1 Answers1

0

You are right, the mega can't do what you want unless something in the middle catches the serial/IO and translates to a keystroke command.

Another option, more expensive, is to buy an Arduino Leonardo which is also available as a small usb stick type of device. Then use serial/analog or ano from the mega to the Leonardo.

The Leonardo boards can emulate any usb device such as keyboard, mouse, joystick etc.

Maybe not of interested but also look at Teensy 3.1. It can do what the Leonardo does but is 32 bit and very flexible. The only benefit of the mega is the massive number of pins. Teensy costs about $20.

It all depends on what your project requires.

Visual Micro
  • 1,027
  • 6
  • 13