Simulate KeyBoardStrokes with Arduino Uno

Hi there!

I have Arduino UNO and I would like to create 4 buttons where:

  • If I press the button 1 the Pc press "a" on the keyboard, if I press button 2 "b", button 3 "c" and button 4 "d".

To be more specific: I want write on MicrosoftWord Document NOT using "a" on the keyboard but pressing the button 1 created with Arduino. I need only 4 buttons, not more.

Hope to be clear.

Thanks a lot!

sorry, the Uno will not do that. A micro or a couple of other boards will emulate a keyboard, but not the standard Uno or Mega. This is from the keyboard reference:

These core libraries allow a 32u4 based boards or Due and Zero board to appear as a native Mouse and/or Keyboard to a connected computer.

Look here

There may be a shield available to add the function. I'm not sure.

Totally wrong approach!

USB keyboards cost a few dollars, $1 or less if second hand, free if keys missing.

Open it up, remove the PCB assembly and work out which connections correspond to each of the keys you want to encode.

Compact, simple, cheap, perfect performance.


nathancamp:
sorry, the Uno will not do that.

Actually, a UNO can, where a Duemilanove/ Micro Nano cannot.

Paul__B:
Totally wrong approach!

USB keyboards cost a few dollars, $1 or less if second hand, free if keys missing.

Open it up, remove the PCB assembly and work out which connections correspond to each of the keys you want to encode.

Compact, simple, cheap, perfect performance.


Actually, a UNO can, where a Duemilanove/ Micro cannot.

From the Micro product page:

The Micro is the smallest board of the family, easy to integrate it in everyday objects to make them interactive. The Micro is based on the ATmega32U4 microcontroller featuring a built-in USB which makes the Micro recognisable as a mouse or keyboard.

And if you look at my video #30 you will see how a Sparkfun Pro Micro / Leonardo sends back keystrokes to your PC (acting as a keyboard). URL in the footer of this post.

@Paul__B I don't understand what to do at the end!

I need for split buttons, Can I or Can't emulate a keyboard with Arduino Uno? If yes, what I need to buy more?

Thanks

TeoFunk:
Can I or Can't emulate a keyboard with Arduino Uno? If yes, what I need to buy more?

No you can't.

Only an Arduino board that presents a virtual USB port or which has a separate USB port will allow this (such as the Elektor UNO v4).

An Arduino Micro or Leonardo will work as will a Sparkfun Pro Micro - basically one that has a 32U4 on board programmed to deal with USB instead of, say, a CH340G chip as found on UNO clones.

Ralph_S_Bacon:
No you can't.

Yes you can. :roll_eyes:

A real UNO has a 16U2 which can emulate a HID. It is already emulating a serial port.

Paul__B:
Yes you can. :roll_eyes:

A real UNO has a 16U2 which can emulate a HID. It is already emulating a serial port.

Are you talking about flashing the ATMega16U2 to support other emulation modes as in these pages?

http://www.kevindemarco.com/2014/01/02/arduino-uno-as-a-usb-hid-interface/

http://pmb.neongrit.net/blog/?p=1

http://mitchtech.net/arduino-usb-hid-keyboard/

It looks fairly complicated, but it does seem to work.

The other processors mentioned handle the keyboard functions natively.

nathancamp:
It looks fairly complicated

ROFL! I don't know what part of the world you're from but that is most definitely a true "typical British understatement"!

I wonder if Paul__B truly expects a noob (of the sort that asks this sort of question) to even understand those links. Let alone implement them. All for the sake of a $2 pro Micro that does it " out of the box ".

But, as always, he is correct.

I was actually anticipating some further discussion about what a "real" UNO is.

It is somewhat annoying that (irrespective of the copyright considerations) bogus devices using a CH340 are being fraudulently advertised as "UNOs" where clearly they are not at all related to the UNO.

Without a 16U2 (or the earlier version) they are nothing more nor less than a Duemilanove clone or variant.

(OK, it's a hobby horse ... :roll_eyes: )