Edit: What I'm looking for is some kind of library which could be used with an arduino to read the HID protocol output from the Data+ and Data- cables of the USB.

========== If I cut the cable of a usb keyboard, plug in power and ground can I use the clk and data wires to read keystrokes into the Arduino? If so any pointers to libraries and schematics?

Simple I instructions? The "for dummies" version?


Following some of the suggestions below I found this:


Which looks like what I want to do, basically hook up the lines into the arduinio and read from the keyboard using the HID protocol in this library.


That doesn't do what I want. Does anyone know how this could be accomplished?

  • From what device do you want to read keystrokes? from an USB keyboard? – chrisl Apr 12 at 17:35
  • yes from the keyboard. – Rick Dearman Apr 12 at 18:27
  • I think you can do this using an USB Host shield. – chrisl Apr 12 at 18:36
  • Which looks like what I want to do ... no it isn't ... read it again – jsotola Apr 12 at 20:26
  • If it is possible to make an AVR bit-bang the USB protocol as a device, it may also be possible as a host. Have you tried to find such a library or project? – the busybee Apr 15 at 9:01

USB doesn't have data and clock lines. It has a pair of data lines with inverted polarity (D+ and D-). The USB protocol is considerably more complex than you seem to imagine.

However there is a caveat: some keyboards have the ability to work in IBM PS/2 mode. For this you will need a USB to PS/2 adaptor (pictured below) and then use the PS2Keyboard.h library. Your mileage may vary, though, as not all keyboards will work.

enter image description here

  • Any place I can get information on this protocol? I don't want the adapter, I want to plug in the cables directly and manipulate the data. – Rick Dearman Apr 12 at 18:28
  • 1
    I think you don't actually need the adapter. It should just connect the pins of the USB jack to the pins of the PS/2 plug. So you could just directly connect the lines to the Arduino. A very short google search gave some promising results – chrisl Apr 12 at 18:38
  • These adapters only work if the USB keyboard has a dual controller which understands the PS2 protocol as well as the HID USB protocol. (Most modern keyboards don't) I don't have one of those, and I am looking for a library or method for directly interfacing the HID protocol with an Arduino. – Rick Dearman Apr 14 at 22:01
  • 1
    Then you will need to invest in a usb host shield. – Majenko Apr 14 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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