The Arduino is perhaps the coolest thing on earth. There are many types, the Uno, the Mega, the Pro, the Pro Mini, etc. etc.

But one thing that often can be a problem is that you only have a limited number of inputs and outputs. There are many solutions for that, ranging from multiplexers to port expanders. But one thing that gives you up to 171 extra inputs is to use an old keyboard. And that is that this instructable is going to be about.

(The image it an example of things that can be used with this. As you can see, I only put up switches and relays. What's because the keyboard controller only can handle non-time sensitive digital inputs.)

Step 1: What You Need

What do you need? First, an Arduino. Second, an old Keyboard what still works. And that's pretty much all.

1. An Arduino.
2. An old  PS2 keyboard. It will work with a USB keyboard, but will be extra work and will not be covered here. (You only need the controller PCB)
3. A PS2 jack. Optional, you can also cut the cable.
4. Some buttons or relays and some wires to connect the buttons to the controller PCB with.
5. The Arduino IDE . There are enough tutorials on how to install it spread around the WWW.
6. The PS2Keyboard library. See further down on how to install it.
7. A good idea to use this with.

Please note what the keyboard in the image is not the one I used. I have already demounted my keyboard long ago.

Installing the library:
1. Go to this page and click on PS2Keyboard.zip. A window will now come up asking what you what you want to do with the file. Click on open.
2. You will now have an explorer window (on windows. I can't help you with other operating systems). Click on Extract all Files up to the left. Enter arduinoInstallPath /libraries (arduinoInstallPath is the place there you installed the Arduino IDE) and then click on Extract.
3. Go to arduinoInstallPath/ libraries/PS2Keyboard and delete the file "PS2Keyboard.cpp.o".
4. Done.

Step 2: Connecting the Arduino and the Keyboard

After you now have all software installed it's time connect the Arduino with the Keyboard. In this instructable I will cut the connector of from the cable, but if you later want it to be easily plugged into something it can be a good idea to use the connector.

1. Open up the Keyboard. You can throw away anything except the controller PCB and the cable.
2. Use a Dremel or a sandpaper and make the small black pads on the controller PCB shiny by polishing them.
3. Solder wires to the polished pads. This can be hard, and you may need some practice, but it will work after some time. In the photo you can see two of the wires soldered to my controller PCB. as you can see, one of the pads in the right group was damaged as I tried if it would be easier to drill holes into the PCB for soldering the wires.
4. Then all wires are soldered. You can connect the PS2 cable to you Arduino. Use this schematic here for that. To find what cable goes to what Arduino contact, it can be useful to have something to check if there is a connection, the schematic and this .
5. Done!

If you want to find out what two pins are connected to what letter, use the code attached to check. Create a map somewhere on your computer, name it "keyboard_to_serial" and add the attached .pde file into that map. Open the Arduino IDE and open up the file. Upload it and then open the serial monitor. If you now connect pads of the PCB, the key what would have been pressed is shown.

Step 3: Writing a First Program

Thanks to the library, it's very easy to write a program to get keypresses from the keyboard. You only need 5 functions. The attached .pde file has comments on that the different functions do, so it's easy to make an own program with that.

So, what was it. Now it's up to you. A security system with many sensors? A big keypad? A space control room with many buttons?
With this tutorial you have about 170 inputs for the cost of 2 digital pins of the Arduino. A fare trade, huh?

If you have any questions, post a comment or PM me at the Arduino forum (username: JanD).

And please vote then the voting starts for the Keyboard vs Mouse contest.
<p>&quot;4. Then all wires are soldered. You can connect the PS2 cable to you Arduino. Use this schematic here for that.&quot;</p><p>Am I missing something? I don't see a schematic.</p>
Is there a way to do this with a usb keyboard on an arduino unto as I really need extra inputs and don't have much funding
<p>would this method be suitable for making a musical keyboard for a synthesizer?</p>
<br><p>Hate to say it but not all of the inputs will work at the same time due to keyboard ghosting</p><p><a href="http://www.microsoft.com/appliedsciences/antighostingexplained.mspx" rel="nofollow">http://www.microsoft.com/appliedsciences/antighost...</a></p><p>basically this means that only some of the inputs will work at once because the are in a grid this will tend to make the project less useful but it is still really cool and usful for many other functions</p>
This is a pretty cool idea! Thanks for sharing. I think it would really help to give some more information on how it was made and maybe break out the steps a bit more. Good job!
Thanks.<br><br>What do you think about them saying break out the steps?<br><br>JanD
First of all, if you came up with this at the age of 14, sweet, good job! <br> <br>What she means I think is, that you have 3 quite big step at the moment, and you could make them into say, 6 smaller steps. For example, in step 2, you start about opening the keyboard and end with programming the Arduino when you've completely dissasembled the keyboard and connected other &quot;stuff&quot; to it. You could make two steps out of that, say: step 2 is the dissasembly of the keyboard, and where to make connections, and step 3 for programming the Duino. <br> <br>Just a suggestion, have fun using stuff for what it was not intended to do! :) <br> <br>Thom
This is ingenious. And you came up with this when you were 14? Have fun at NASA ! <br>
Don't damage that chip? That is about impossible because the black epoxy covering it cannot be melted by a soldering iron. However, I might test that epoxy on a Dremel with a profiling (circuit board drilling) bit. But I'm not going to use an expensive keyboard PCB; I'm going to use a cheap TV game PCB.
This is agreat idea, but I have a question. It's obvious you can get inputs from the keyboard, but can you output to the board? I guess the question is really if this is one-way. It could vary I guess if there are diodes.
The only reason I'm suspicious about outputting to the keyboard is because if you enable the on-screen keyboard you can toggle the lights and function of the physical keyboard's Num Lock, Caps Lock, and Scroll Lock.
If you only supply power to a keyboard, pressing the lock keys will not toggle the lock lights. That's because the USB or PS/2 host has direct reading of the lock keys, and is the only computer to control the lock lights (the keyboard just does as it is told).
I've also thought about that, and i think it should be possible, but as far as i know not with the library i use.
a comment on step 2 (Wndows file downloading)<br> <br> On Linux (Ubuntu 8.04 - hardy, Firefox 10.0.2)<br> <br> When I left-click on download link link, a windows opens with 4 options (depending on your add-ons):<br> <br> 1 - Open with Archive Manager (default)<br> 2 - DownThemAll<br> 3 - Save file<br> 4 - dTa OneClick<br> <br> There's also a check box:: &quot;Do this automatically for files like this from now on&quot;<br> <br> My first option is DownThemAll. It's a great Firefox add-on.<br> <br> Select it and the &quot;Add downloads&quot; windows opens<br> <br> Check your destination folder and press the &quot;Start&quot; button The DownThemAll main window opens with your file for downloading. When finished, the progress bar will show 100%.<br> <br> If you hover with your mouse on the download name, you will see some info about your file, the most important: destination path in case you forgot where that was.<br> <br> Now you can (1) go to than folder or (2) right-click on name and select an option or (3) double-click to open your downloaded file.<br>
I guess another question is how can you figure out which key scan be used at the same time. It seems more keys in certain areas work together than keys from other areas on a standard keyboard.
Depends on how fancy a keyboard you use<br><br>http://en.wikipedia.org/wiki/Rollover_%28key%29
Basicly, the only thing you have to do (on a programming side) is to read the keys with simple functions.<br><br>On a hardware side, the only thing you have to do is connect switches between the two groups (as in a matrix) and then try your way to find what two positions are what key.<br><br>Jan
some schematic of how to connect the switches, and what mean each cable color from the ps2 output.
As I think that most keyboard controllers are quiet different, I think that can be hard, but I'll see what I can do.
quite*<br><br>wha'ts with the (.temp);<br>i like your instructable, but I think it needs more information about those relays and schematics.<br><br>

About This Instructable




Bio: I'm only 14 years old, so don't expect my instructables to be as good as if a 30 year old engineer had done ... More »
More by 02JanDal:Extra inputs for Arduino with a keyboard Arduino on all sorts of Atmels 
Add instructable to: