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?
EDIT
Following some of the suggestions below I found this:
https://github.com/julianschuler/USBKeyboard
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.
EDIT 2
That doesn't do what I want. Does anyone know how this could be accomplished?
1 Answer 1
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.
-
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– Rick Dearman04/12/2021 18:28:46Commented Apr 12, 2021 at 18:28
-
1I 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 resultschrisl– chrisl04/12/2021 18:38:09Commented Apr 12, 2021 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– Rick Dearman04/14/2021 22:01:34Commented Apr 14, 2021 at 22:01
-
1Then you will need to invest in a usb host shield.Majenko– Majenko04/14/2021 22:18:21Commented Apr 14, 2021 at 22:18
Which looks like what I want to do
... no it isn't ... read it again