I am considering connecting a ThinkPad X4x keyboard to a PC, using a programmable KeyWarrior keyboard controller in between the keyboard's ribbon cable and the USB cable to connect it to the PC. Not being an electronics guy, I checked back in the KeyWarrior forum and was told that this should work. The necessary parts are all easy to obtain, and I know how to use a soldering iron. ;-)

Anyway, everywhere I hear Arduino, and it would probably be worthwhile to learn about this universal microcontroller. Would it be possible to replace the KeyWarrior solution by an Arduino solution?

Note that the KeyWarrior16 supports two layers, for the FN key on the keyboard.

I now also opened a thread in the Arduino forum.

  • \$\begingroup\$ Do you have a pinout for the ribbon cable on the ThinkPad keyboard? \$\endgroup\$ – Pablo Maurin Mar 28 '13 at 0:53
  • \$\begingroup\$ @PabloMaurin No. Unless, I find them somewhere online, that would mean trial and error. \$\endgroup\$ – feklee Mar 28 '13 at 9:11

Yes. There are three things you would need to do. The first is the keyboard matrix. Keyboards are normally made using a matrix of outputs to inputs, where each key on the keyboard corresponds to one combination of in and out. 8x8 is a common matrix. Smaller phone keypads are an example of 4x3 and 4x4 matrixes, and are commonly used in Arduino projects.

The second part and third part are intertwined. The second part is the protocol to the computer. Serial, PS/2 or USB are common ones, with USB being the most recent (bluetooth as well, but that's wireless). Serial and PS/2 can be bitbanged, as can USB, but it is slightly harder. V-USB is a project for software USB implementation on ATTINY and ATTMEGA (like the arduino) processors.

The third part is the actual code between reading keyboard matrix, and sending it over usb. On the USB side you want a USB-HID keyboard (driverless on the PC side). On the keyboard side, you can use polling or interrupts. Your code would decide what matrix combination is what keyboard key, and what keyboard scan code.

The Function keys are essentially handled by software, same as the shift/control/option/command/windows key are. Your code would read the function key being pressed, then any other key being pressed would send the key+function scan code, instead of just the key scan code.

Simply googling "Arduino USB Keyboard" will give you a literal google of example projects doing as such. Also "Arduino Keypad".

  • 1
    \$\begingroup\$ The newer Arduino boards use a 'u' series atmega with a hardware not software USB interface, either as a converter (uno, mega) or as the main programmable device (leonardo). Software USB is possible on a regular atmega, but is not as robust. \$\endgroup\$ – Chris Stratton Mar 28 '13 at 1:58
  • \$\begingroup\$ Would PS/2 be easier to interface with? Because I need to add a PS/2-USB converter anyhow: The TrackPoint pointing device on the keyboard directly emits PS/2. \$\endgroup\$ – feklee Mar 28 '13 at 9:15
  • 1
    \$\begingroup\$ @feklee see this hunt.net.nz/users/darran/weblog/329aa but if you want to use a ps2 touchpad on usb, a cheap ps2 to usb adapter (like 1 dollar on ebay) is all you need for that. The keyboard is different because most older laptop keyboards are just the matrix, without a controller on board. That said, emulating ps/2 is easier than bitbanging usb-hid. See: arduino.cc/forum/index.php?topic=19224.msg140627#msg140627 and playground.arduino.cc/ComponentLib/Ps2mouse \$\endgroup\$ – Passerby Mar 28 '13 at 9:42
  • \$\begingroup\$ @feklee You will still need to make up the matrix scanning part, but you could plug it into the same usb-ps/2 adapter you'd get for the touchpad, since they normally have a keyboard and mouse input option. \$\endgroup\$ – Passerby Mar 28 '13 at 9:43
  • \$\begingroup\$ @Passerby Yes, I'm talking about the bitbanging part. Many cheap PS/2-USB adapters won't work, though, as they are only for devices that already speak USB. It's not a touch pad, by the way. \$\endgroup\$ – feklee Mar 28 '13 at 9:58

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.