Things used in this project
|Hand tools and fabrication machines:|
8:30pm on Saturday, 12 hours into the first day of our DC hackathon, I was severely sleep-deprived. Making this thing kept me awake until 11. Which is great, because it serves no other earthly purpose!
Also, one of the participants didn't think I'd finish it, so he said that if I could write his name with it by the end of the night, he'd create a Twitter account just to tweet about it. (He later tried to give me an hour time limit. I came close - 70 minutes – even though I don't consider it legit to impose constraints after the fact!)
So this is for you, Daniel.
Why binary? Because you get 31 numbers on one hand, which is just enough for the alphabet and a few essentials. Because it helps me get more intuitive with binary counting. Because it's useful to learn which letter is numbered what, if you're into codes and things (such as the classic ROT13).
Why the Teensy? This board can act as a USB keyboard – I built this out of the super easy tutorial. Also, as the name implies, it's teeny-tiny.
And... just... why? I've been wanting to build something like this for a long time, so I could write down some notes about my dreams, with one hand, without fully waking up. Also, as part of a sort of personal electronic environment. Also, simply because I like building keyboards...
That one was extremely tough to use, because I had simply hijacked the circuitry of an existing USB keyboard, which doesn't give the letters intuitive key combos.
But... this project was really just an excuse to use some tiny buttons and haptic motors, since it's our last HardwareWeekend and we've got millions of them!
So, I stuck some buttons in a breadboard, where it's comfortable to grip them...
Next, the code... I needed to figure out how to time the buttons, so that I would be sure to read all of them at the same time.
At first, I was going to make an "if/and if/else..." tree, but it would have been MASSIVE!
Instead, I added a haptic motor to signal when it would read.
The code is on a 1-second loop, so you can send maximum 1 character per second. As you improve, of course, you can go faster.
Here's the breakdown:
- Set up the digital pins, etc.
- Turn on the haptic motor for 1/4 of a second (250ms)
- Read all buttons
- Print the resulting binary code, if anything was pressed
- After 250ms, turn off the haptic motor
- Pause for half a second and start again at step 2.
The encoding is inspired by this awesome haptic beatboxing controller that Adam John Williams built at MTF '14. Basically, you can count on your fingers in binary, which gives you 31 possible options on each hand. That's 26 letters + 5 characters.
Binary finger counting
So, each finger is a 1 or a 0.
Thumb is the ones place (2^0 = 1). So, all fingers down is 0, and a thumbs-up is 1.
Index finger is the twos place – because we're in binary, base 2, instead of decimal, base 10, and 2^1 = 2. So, you can now add two to your thumb: 10 is two, 11 is three.
Middle finger is the fours (2^2 = 4). 100 is four, 101 is five, 110 is six, 111 is seven.
Ring finger is the eights (2^3 = 8). 1000 is eight, 1001 is nine, 1010 is ten... and so on. 1111 is fifteen (8 + 4 + 2 + 1).
Pinky is 2^4 = sixteens place. The maximum you can have with five digits is 11111 = 31. It's easy to find: The next place would be the thirty-twos (2^5), so the max with five fingers is 32-1 = 31.
See the video below for a demo!
Buttons to numbers
Instead of trying to calculate anything or do an if/then tree, I made this easy with math:
Start with 0.
If the thumb is pushed, add 1.
Index = 10, middle = 100, ring = 1000, pinky = 10000.
If any buttons were pushed, send the resulting number to the screen.
If no buttons were pushed, don't print anything!!! I learned that lesson after my tests kept editing their own sketch – I'd click "Upload" in the Arduino IDE, then the keyboard would restart and start printing 0s into the sketch itself that I had open. D'oh. Also, you don't get big rows of 0s when you stop typing.
Make sure to use the Teensyduino setup, and pick "Keyboard + Mouse + Joystick" under Tools > USB Type.
Now, I had to wire and solder everything together. Disclaimer: The physical construction of this thing is aggressively awful.
This was a giant pain, because I chose a common ground wire that is very resistant to heat (probably because it's so thick) and wouldn't take solder well. It's a stranded wire, and I ran it down the center groove of the breadboard and split off individual strands to each button. The other leg of each button was routed to a digital input pin.
Also, I should not have been soldering on top of a breadboard. Holy plastic fumes. Use good ventilation!!
But... TURBO HAX
Anyway, yeah, I soldered the finger buttons and haptic motor in, on the pins listed in the sketch. Sometimes I just put a glob of solder on the button leg and twisted the ground wire around it, because they wouldn't solder together. The motor got its own ground because I wasn't sure at first how it'd be connected.
Then, I tested it (woohoo, positive function!) and hot-glued the **** out of everything.
This thing is really annoying to use. And probably bad for your nerves. I'm gonna make the vibration MUCH shorter, especially when I'm better at using this.
However, it works! It does help you use and read binary.
The vibe pulses tell you when to get ready, and when to type. It could become intuitive very quickly.
The button I swapped in for the thumb is comfortable to push with the side of my knuckle, as ones's grip naturally rests.
It's lightweight and pretty small.
I will definitely keep using this!
I thought about adding haptic rings to give you feedback about the letter you just typed. But, having used it, that seems like a terrible idea. Lights might work, though! And they'd be cooler for people to look at, and would help others understand.
Finally, I might write another sketch that lets it send MIDI data!
Now, back to running my hardware table...
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!