Teensy powered Apple mechanical keyboard

I learned to type sometime in the 80’s on a manual typewriter and presumably this is why I am fixated on mechanical keyboards. If you’re not much of a touch typist (or keyboard geek) you’re probably not aware that modern (inexpensive) keyboards are an abomination unto typing.

The IBM Model M keyboard is perhaps the most famous clicky keyboard with manufacturing spanning 1984 until the late 90’s and a company purchased the manufacturing line and still produces a variant to this day. Their enduring popularity and sometimes surprising price tag on the second hand market is testimonial to their design and build quality.

Modern day mechanical keyboards are manufactured and popular with typists, gamers, and aficionados. Das Keyboard offer undeniable quality for Mac, PC and Linux. They even offer an uber-geeky blank keycap variant to totally confound your visual based two fingered typing coworkers. Due to their specialist and somewhat niche market however these keyboards cost twenty times that of a cheap membrane keyboard.

History lesson and personal typing preference aside however I’m also a fan of retro computers so when I learned of a project to modify a keyboard from the late Steve Jobs NeXT computer company into a modern functioning USB device I was more than interested.

As I didn’t have a somewhat rare NeXT keyboard in my junk box I tracked down an older Apple mechanical Extended Keyboard II for a tenth of the price of a second hand Model M.
NeXT used a proprietary communication protocol to link their keyboard and computer, and early Apple did exactly the same thing with Apple Desktop Bus (ADB) – an early ancestor to our modern day device independent USB protocol.
Whilst there have been various commercial ADB to USB adapters produced over the years building one from scratch proved to be a much more satisfying experience.

After purchasing a Teensy 2.0 USB development board I downloaded the necessary software

I cannot thank the Geekhack crew enough for providing this source code for others to utilise. They saved me hours of reverse engineering and hardware sniffing and made this project a breeze.

Unlike the super-friendly Arduino IDE I had to manually build and compile my own firmware from the command line before flashing it to the device using Teensy Loader. Presumably because I was using a newer version of the compiler than the author I received a build error:

make: *** [obj_adb_usb/common/xprintf.o] Error 1

which was rectified by modifying the code in config.h to include a new conditional

/* key combination for command */
#ifndef __ASSEMBLER__
#include “adb.h”
#include “matrix.h”
#define IS_COMMAND() ( \

Be sure to keep the original endif below the code block when pasting the patch.

Update 02/06/2014 Somehow I missed the Teensyduino extension which provides a more familiar GUI for those not wanting to experiment with the command line. Thanks Nantonos!

The Teensy board needed to be connected to the keyboard power 5v, ground, and signal. As I placed the board inside my keyboard case (now you see why size is important) I didn’t need any further modifications. Other people modifying this keyboard who placed a significant length of wire (such as an ADB cable) between the keyboard and Teensy needed a pullup resistor between the signal and power lines. I had to use a 1K resistor when testing using a breadboard and external cable, but after placing the Teensy inside the keyboard with virtually no wire length it became unnecessary.

Connect the keyboards ADB (data) pin 1 to Teensy pin F0, pin 3 to Teensy VCC (5v) and pin 4 to Teensy GND (ground). If you need a pullup resistor (in the 1-10k range, you may need to experiment) it will link ADB pins 1 and 3.

alps circuit board
High quality ALPS keyswitches are what make all the difference
alps circuit board
ADB socket removed, wires tapped in to the circuit board and heatshrunk ready to attach to the Teensy
Teensy installed
Teensy connected to USB and ready to be installed. I wrapped it in insulation and tucked it out of harms way.
Completed keyboard
47cm wide and weighing in at 1.7kg. Amusingly the MBP it is attached to weighs 2.02kg.

I love the coloured old apple logo top left and whilst it certainly creates the distinctive clacking sound of a mechanical keyboard it is not unbearably loud and coworker irritating. Perhaps Jethro Carr could have used one and avoided the banning of his beloved Model M’s.

If you would like to hear the sound of this keyboard head on over to Shawn Blanc’s article.

Edit 17/02/2014 I have just made another of these keyboards as I’ve become accustomed to using them and felt I was missing out at while I was at work. I had a bit of difficulty tracing the ADB pin outs this time as it was a slightly different keyboard (Apple Extended) A great reference is the ADB Apple Desktop Bus pinout

Raspberry Pi SD card setup

Whilst following the instructions available at enlinux I had repeated errors whilst attempting to move my OS image to the SD card for the Pi to use. Specifically this line:

sudo dd bs=1m if=~/Downloads/2012-10-28-wheezy-raspbian/2012-10-28-wheezy-raspbian.img of=/dev/rdisk3

What ended up solving the problem for me (after much hair pulling) was to not use the built in SD card reader of my MacBook Pro, and to use a cheap external USB dongle. Sometimes it is the most simple thing.

Using Google to host jQuery

Using Google to host your jQuery (or other applicable content) has several advantages over hosting a version on your own server including better caching, decreased latency, and increased parallelism. There are plenty of other articles to discuss the merits of decreased latency benefits of a CDN or the effects of parallelism on browsers so it wont be covered here.

Perhaps the most compelling reason to use Google to host your jQuery is that your users actually may not need to download it at all. If you’re hosting jQuery locally then your users must download a copy at least once. Your users probably already have multiple identical copies of jQuery in their browsers cache from other sites, but those copies are ignored when they visit your site.
When a browser sees references to a CDN-hosted copy of jQuery it understands they all refer to exactly same file. The browser trusts that those files are identical and wont re-request the file if it’s already cached.

So, now that we know that Google is a good place to serve up our jQuery from how are we going to do it? I believe the best way is also the simplest:

<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”></script>
<script>window.jQuery || document.write(‘<script src=”js/libs/jquery-1.7.1.min.js”><\/script>’)</script>

This will point to Google to host the jQuery library, but fall back to local hosting in the event of connectivity issues.

Netgear DG834N dead WiFi

The problem began when both the green WiFi light on the DG834N (v1) ADSL/router stopped functioning and the ability to see the SSID being broadcast ceased. It seemed nothing had changed and during transport from one location to another it had simply died.

To begin with I flashed the latest firmware to the device. It is really important to do this via a wired connection to these devices; often if you perform the operation via wireless the upload of the firmware partially fails and the device ends up becoming a brick. You have been warned!

With new firmware I rebooted the device and at this point the WiFi light turned green. I congratulated myself and expected to find the SSID being broadcast as per normal. It was not to be however, and many hours were about to be spent solving the problem.

I tried many resets – including a hard reset. To perform a hard reset hold the reset button in for 20 seconds with power, continuing to hold the reset button but remove the power for 20 seconds, and finally connect the power while still holding in the reset button. So: 60 seconds holding in the reset button, 20 powered, 20 unpowered, 20 powered. If this reset works properly the power LED will flash between red and green.

After a phenomenal amount of searching the internet I found a few clues to the issue and eventually solved it.

The WiFi component on this model is a plug in module that can sometimes become loose. Open the case, pull the module out, and re-insert firmly. The module is instantly recognisable by the two antenna wires that attach to it.
Note: There are two torx screws that need to be removed underneath at the base and also two underneath the large sticker label at the rear of the unit.

The future:
Apparently the chipset on this model is notorious for heat generation eventually leading to failure. A future mod for this device could be using a dremel to carve out a hole in the chasis and subsequently add a fan to improve airflow.
With the simple plug in antenna arrangement these could also be replaced; however I have had no issues with WiFi performance.
The power supply that comes with these devices are also reputed to be quite underpowered. Mine seemed quite heavy duty so I dont think I will need to replace it unless the addition of a fan increases the current draw too much.