Tuesday, 31 December 2013

DIY Cheap Keyboard Encoder

I have been thinking about building a pinball machine and at first, I thought about using an Arduino as the controller.  After giving is some thought, I decided that I would use a computer as the controller and use an Arduino for some specific functions in addition to the computer.

Oh ... and I wanted it to be cheap.

So how do you get all of the switches that you need for a pinball machine to communicate with the computer?  The first idea was through the Arduino but really didn't seem practical and it certainly was not the cheapest and easiest solution.

I started researching and found an interesting product in the I-PAC.  The price was reasonable and the product looked solid but at about $45, I thought I could do better.  After some research on building a custom keyboard encoder, I had my "light bulb" moment:  every USB keyboard has a built-in keyboard encoder that can be cannibalized.  If I didn't have a spare USB keyboard, I could buy one at the dollar store for $3.

I bought the dollar store keyboard and disassembled it.
This is the underside with the switch membrane removed. 

The keyboard encoder is simple enough.  The connections are arranged into Rows and Columns to form a matrix.  Pushing a key closes the connection between a row and column.  It is the job of the keyboard encoder to check the rows and columns and send a signal to the computer with the code for key pressed.

Here is the circuitry from the keyboard.  They leads on the printed circuit board were coated in a black substance which I scraped off to test the unit.

After plugging in the USB connection to the computer, I used a small jumper wire to connect random rows and columns to see what would happen.  Using the program Notepad in Windows, here are the results:
 
You can see that the keyboard encoder works and sent characters to the computer.  Since this is a 101 key keyboard, I have at least 101 inputs available for switches.  Here is my cheap keyboard emulator!

This system works for mechanical SPST (single pole single throw) switches but I also need to include some sensor switches and I haven't figured out how I am going to do that yet.  If you have ideas, I would like to hear them in the comments section.