Hello.
I've been interested in working with arduino for a while, and I just bought my very first board (pro micro), I'm 100% new at this.
I've seen a few tutorials using the pro micro as a keyboard but they all use some kind of trigger, like a button, to send a keypress.
Since I don't have almost any parts yet, I'm wondering: isn't it possible to connect the arduino on the computer USB and send commands to it via serial port from a software to trigger the keypress?
It would work like this: my software sends a message requesting a keypress for 'r', and the arduino sends such keypress. It would be like an interface to sort of make my simulated keypress "real".
If this is possible, can I do it just plugging the arduino in without any other hardware?
FYI there is no chip called a "pro micro". There is an Arduino board called a Pro Micro and it contains a chip called atmega32u4.
If I understand correctly what you want, the Pro Micro would need to act as both a serial device and a HID device at the same time. I don't know if it can do that.
But it seems like a strange idea. Your software would send a request for an 'r' and the pro micro would send a r keystroke back? Is there not some simpler way to achieve that where the pro micro is not required?
Well, it is just a start. The purpose, like I said, would be to programmatically inject "real" input into the system, which can only be achieved via hardware or a custom kernel mode driver. Since the pro micro can be used as both keyboard and mouse, it is quite well suited for this purpose.
DirectInput, for instance, just ignores simulated input. Also, it can use HID identifier from a driver to guess whether the input came from a device or software, even if it is not marked as so by the operating system. So, having control over a piece of legitimate HID hardware to make it send keypresses and mouse movement and clicks is actually quite useful in many scenarios.
One interesting application of the Pro micro - or similar devices - is to make a "pest" dongle that when plugged into a PC, generates occasional keystrokes or bursts of specific or random data - or mouse movements.
That might be a form of your exercise. Generate a slow mouse wander.
This works perfectly, thank you!
By the way, the device is currently listed under "Ports (COM & LPT)" AND as HID Keyboard Device under Keyboards, so I guess it is possible for it to act as both at the same time.