Introduction: Multimedia Keypad
I recently got a new keyboard from Das Keyboard and love it. However, one of the drawbacks is the lack of multimedia keys (volume, play, next song, etc...). I really didn't want to NOT use this keyboard, so I decided I'd make something to replace the lost functionality.
This is more of a story of what I did, rather than a full on how-to. Mistakes were made, tears were shed, but I got a very useful keypad out of the ordeal and I hope that this information might be useful to someone else.
Just as a disclaimer: The multimedia key functionality of the Teensy doesn't work in Windows for some reason. All of the rest of it does, just not the multimedia keys...
Step 1: Materials List
- Altoids Mints tin
- Adafruit Perma-Proto Quarter-sized PCB
- A Rotary Encoder
- Tactile Buttons
- Teensy 2.0
- A couple of 10K Ohm resistors
- USB cable
- Some wire
- Two M3 screws (8mm)
- Soldering Iron
- 3D Printer (Not completely necessary... I just happened to have one)
- A hand drill
- Flush Wire cutters
- Misc clamps (I used a few large binder clips, also)
Step 2: Design
The design of this thing isn't really all that complicated at all... Thanks to the wonderful tutorials and documentation over at PJRC it was really just straight forward plug in the buttons and run the code (the rotary encoder was a little more involved, but only just).
Step 3: I Like Pressing Buttons.
I soldered six buttons to the PCB, and took careful measurements of how far apart they were, how big the buttons were, etc... important information to know when making the cover panel.
These round tactile buttons that i ordered from Adafruit are nice, but they have a pretty big footprint. The Adafruit Perma-Proto board has a nice small footprint, but it's designed for stacking things only in one direction. I wanted to stack these buttons both ways, so I had to get a little creative and cut a few traces along the back of the board.
I'm sure there is a more elegant way of doing this, but this is what I had available to me.
Step 4: Paneling
I printed out the attached 3D file, which may still have some cruft in it from the first design that I tried (without the rotary encoder) to make the panel. You don't need a 3D printer, though, you could easily do this with a piece of lexan and a drill to make room for the buttons.
Conversely, you could also just drill holes through the tin itself, which is what I originally tried to do, but the drill mangled the thin metal pretty harshly. I need to learn a finer touch...
I used some epoxy to attach the panel to the tin after cutting out a large enough hole to accommodate the buttons.
Attached are the SCAD files if you would like to print them.
Step 5: Insulation
The funny thing about electricity is that it doesn't really care about how it gets from negative to positive. Therefore, we have to take some measures to make sure that it gets from one end to the other in the way we want it to. Plastidip is a very nice way to insulate just about anything electrically. I poured some into the bottom of the tin, spread it around a bit, and let it dry. Instant floor!
Step 6: Support Group...
I needed a way to keep the buttons secured to the lid of the tin at a fixed distance. 3D printer to the rescue!
Again, you don't need a 3D printer for this, but man, does it make it convenient... somewhat...
I printed out two of these support "beams" (included in panel.zip in step 4) with a screw hole large enough for a couple of M3 screws.
The bowing effect is due to the print peeling off of the print bed, something that I need to work on, but does not affect this build as there is still no side-to-side flex of the PCB because the screws have such a firm hold.
With these supports made, I epoxy'd them into place on the underside of the lid, and used the same high tech clamping method as earlier. I failed to grab a picture of this step...
Step 7: Putting It All Together...
Wiring it up could have been a little better with a little foresight on my part. Soldering the wires to the underside of the PCB could have been a lot easier had the switches not already been soldered on.
Also, it's time for a hole to be drilled for the rotary encoder to be placed into the lid of the tin (again, I forgot to snap a picture of it), you can see it vaguely here.
Step 8: USB Cord
Since the Teensy uses a mini-usb connection, and I wanted it to be as internalized as I could make it, I divided the usb cord at a couple of points... this also gave me a chance to shorten it to a usable length. I then drilled a hole just large enough for the usb cable, inserted it, secured it with a few zip ties, and resoldered the two pieces back together.
Step 9: Wiring Continued...
I had nearly forgotten about the pullup resistors for the rotary encoder... so, like so much of this project, I improvised...
Wire up all of the buttons. There are two more than were in the prototype (sixth pushbutton, and the pushbutton on the rotary encoder). I left pins 7 and 8 (D2 and D3 on the teensy) open in case I wanted another rotary encoder on a future version, and rotary encoders require a hardware interrupt pin (or that's what they tell me, I believe them. Why would they lie?), and wire the other two buttons up to pins 9 and 10 (C6 and C7 on the teensy).
Step 10: Code the Thing!
The attached source is the code that I used. There is some redundancy in code, as in there are two ways to control volume (two buttons, as well as the rotary encoder), two ways to Play/Pause the music (button/pushbutton on the rotary encoder), as well as a button that i have no idea what to do with... but if I ever do, at least I have room for it. The code was ripped straight from the PJRC tutorials (public domain) with the rotary encoder stuff added to it. The default rotary encoder code (per the examples) was wanting to up the volume 4 times for every click of the dial, which I found unacceptable, so I added a bit to the bottom of it. Please let me know if you find errors or have any comments on how to do things more efficiently.
You can make the Teensy type out just about anything from a single press of a button. Also, this does not work on Windows, for whatever reason. I'm using Linux, and from what I understand it should also work on Macs, but I have not tested this case. I haven't found a whole lot on how to get it to work on Windows, but I'm not terribly worried about it, as I don't use it for anything but games, and have headphones for that. If anybody has any ideas, I would love to hear them.
Feedback is appreciated.