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.

mpromonet
  • 127
  • 6

2 Answers2

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

sa_leinad
  • 3,218
  • 2
  • 23
  • 51
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...

dandavis
  • 1,037
  • 9
  • 12