3

Arduino USB

I want to write an Arduino Sketch (if there is no other possibility it can also be plain c) , to grab keyboard inputs from my ordinary USB keyboard. Preferably without expensive hardware, but as mentioned, if there is no other possibility, this will do it too.

Is this possible with V-USB? I looked a their website, but it seems like this only supports being slave and to imitate a keyboard.

3

2 Answers 2

3

As suggested in the comments, you have two options:

As suggested by Majenko, you can use the Arduino USB Host Shield: Picture of USB Host Shield

Alternatively you could use a PS2 keyboard instead (as suggested by Gerben). Arduino already has a library to handle PS2 keyboards, so the implementation of it would be easy. For reference (and example program) playground.arduino.cc/Main/PS2Keyboard

If you do not have access to a PS2 keyboard or just want to use a USB keyboard, Gerben further suggests that most USB keyboards can be converted to PS2 keyboards with an adapter: USB to PS2 adapter

The keyboard must be able to support both formats (USB & PS2).

The following webpage shows the connections needed to go from USB to PS2: USB to PS/2 adapter pinout

Pinout connection

1
  • Gerben & Majenko, let me know if you would like to post your own answer and I will remove your content from my answer. Otherwise thank you for your suggestions in the comments and I hope I have done your suggestions justice.
    – sa_leinad
    Commented May 18, 2017 at 16:29
2

I am able to use this library: https://github.com/techpaul/PS2KeyAdvanced and USB's data +/- connected to pins 2+3 of an arduino to read keys on standard keyboards.

keyboard.begin( 3, 2); // D3= data+, D2= data-

A standard keyboard is one which doesn't need a driver to work on any computer. I'd tried several libraries, serial keyboard adapters, and ps2/usb converters, and this method works best. Since the ps2-USB converter is just a physical pin change with no logic, standard USB keyboards just magically with with the PS2 libraries; even caps lock and what not...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.