Since I started writing for MAKE, I’ve seen a lot of awesome things that I want to blog
about. There are so many of you awesome makers out there that make lots of awesome stuff.
It’s just really awesome. My problem comes in when I’m writing and the only word I
can think of to describe something is “awesome.” Now of course, I could pull out a thesaurus,
but I figured I’d have a little fun with it and hack something together. So I built
an Awesome Button. Plug it into the USB port of your computer and while you’re writing
if you want to use the word awesome, hit the button and BAM you’ve got a random synonym
for awesome.
Now, I admit, I’m not expecting you to build this exact button, but I did want to show
you how easy it is to build your own custom USB human interface device.... something that
can act like a keyboard or a mouse or a joystick. Let me show you how I built The AWESOME Button.
I made my awesome button out of this Staples Easy Button, they’re about $6, very sturdy
and very hackable. The core component is this microcontroller called the Teensy USB. This
is ideal for our project because this board can easily act like many different types of
USB devices. And we can even program it with Arduino code within the Arduino development
environment. And best of all, look how small it is next to an Arduino. It’s even smaller
than the Nano!
In order to prototype this project, I added header pins to one of my Teensies so that
I could easily breadboard with it. I connected a push button to ground and
a digital pin. Then I plugged it in to my computer to work
on the code.
If you want to use Arduino code and the Arduino development environment to program your Teensy,
you’ll need to install a couple extra things that are available at pjrc.com. The installers
make it really easy. After you’ve done that, in the Arduino development environment, you’ll
need to select Teensy from the Board menu and Keyboard + Mouse from the USB type menu.
Let’s take a quick look at our code. Here we have an array of strings, each of which
is a synonym for “awesome.” Down here, when the digital pin zero gets a low signal,
that is to say, when the button is pressed and it closes the circuit between that pin
and ground, it randomly chooses one of the words in the array and sends it out over USB
as a keyboard. This one simple line will do all the hard work. There’s even a very simple
function for mouse movements and mouse clicks.
Looks like it works well.
I think the hardest part of building this project was actually hacking up the hardware.
Here’s a quick overview of how I hacked up the Staples Easy Button. First I opened
the outer enclosure. On top, there is a circuit board with the button. We’re going to ignore
most of the electronic circuit in the Easy Button and just use the button component in
it.
After you remove this layer of plastic, you can remove the speaker, you’ll need that
space for the Teensy and the USB cable. But you can use that speaker for another project.
I marked off where I wanted the USB cable to come out and drilled a hole there. I originally
thought there’d be enough space for the teensy where the speaker was, but I ended
up needing to cut a slot in the battery compartment and I pushed the teensy through. This minor
set back actually has a silver lining. I can now easily access the Teensy’s reboot button
through the battery compartment door if I need to.
I then soldered wires between the switch and the Teensy’s digital and ground pins.
So I’m never going to get the USB plug through that tiny hole, so I cut the end off, threaded
it through and then reconnected the wires. You could also solder the wires directly to
the Teensy, but I wanted to play it safe.
Be sure you test it out before you pack it up. Looks like it works well.
Getting the whole thing back together is a little tedious and takes a little patience.
Be sure to test it out one more time before you put the last four screws in.
And then that’s it. You’ve got yourself awesome button.
Now as I said, not many of you aren’t going to want to build this exact button, but maybe
there is a custom USB device that you do want to build. Perhaps a Minecraft controller?
Or you could take an NES controller and turn it into a Flickr browser? If you do have a
great idea, leave it in the comments. I’m sure you’re idea will is... incredible.