The PS/2 protocol is fairly straightforward, and the Arduino Micro is easily capable of running a bitbang implementation of the host side. We could also implement this with interrupts if we wanted to, but it is not necessary for this project.

For this project I decided to lean on the excellent TMK Keyboard Firmware. It has a ton a great features - multi-layer key maps, mouse keys, consumer keys, function callbacks for key presses, and more. Only one "problem" - it is written in AVR C with a Makefile based build, and I wanted to use the Arduino IDE to build and load the firmware. So I ported the tmk_keyboard project to the Arduino platform as a library, and creatively named it arduino_tmk_keyboard.

Click the button below to download the library as a zip file.

Getting Started

First, hit the button above to download a zip of the Arduino library. Unzip it into your sketchbook's "libraries" folder:
Next, fire up the Arduino IDE and open the 'terminal_bluefruit_converter' example sketch.
The example will open and you'll see four tabs:
  1. terminal_bluefruit_converter - this is your main sketch, and probably the only place where you'll need to make any actual code changes. The bootstrapping of the firmware and any custom functions are defined here, and your keymaps are configured in this file as well.
  2. config.h - this is the main configuration file; it is included at the top all other code files so it is a great place to define macros, as well as quickly enable and disable features including debug messages
  3. include_api.cpp - this is a hack to properly pull in the library's API classes. Don't touch this file.
  4. include_tmk_.c - this is another hack to pull in the C code from the TMK firmware. Don't touch this either.
Switch the board you're targetting to "Arduino Micro" and make sure you have the right serial port connected. Bonk that checkmark to verify you have things compiling correctly, then lets take a quick look at the code.

This guide was first published on May 06, 2014. It was last updated on May 06, 2014.

This page (Code) was last updated on Feb 20, 2014.

Text editor powered by tinymce.