



Update! My project has been entered in the Instructables “USB Contest” if you like it please vote here: http://www.instructables.com/id/Reddit-Controller-USB-UpvoteDownvote-button/

Not too long ago I saw the “Awesome Button” video on the Make Magazine podcast. In the video Matt Richardson shows how you can take a Teensy development board and turn it into a simple USB keyboard. In his example everytime a button is pressed a synonym for the word “awesome” is sent to the computer. While this is a pretty neat project the idea of creating a simplified keyboard out of a few buttons is what stuck with me. This lead me to start creating my “Reddit Upvote/Downvote button”.

Reddit is a website that has in the past few months taken over my life. Not unlike Digg it aggregates all the best stuff on the internet and makes it easy to consume. The way posts are sorted or brought to the front page on Reddit has to do with the number of Upvotes and Downvotes a post gets over time. Now while these voting options are usually toggled by clicking arrow icons on the webpage they can also be controlled using keystrokes after installing the Reddit Enhancement Suite. After I found this, all the stars aligned for my project.

I started by sketching out a basic design enclosure and making some measurements for the parts I planned on including. The Teensy development board really is teensy so my project box ended up being pretty tiny. In the gallery below you can see the evolution of the project box. I started off with a pretty large box and scaled down to just big enough to fit what I needed. It’s pretty amazing to be able to print a box that fits your exact project dimensions in about 30 minutes. I also printed up and down arrows, the upvote arrow using red plastic and downvote colored blue with a Sharpie. As usual I’ve uploaded my most recent model to Thingiverse as STLs and Sketchup files. These can be downloaded and printed in the comfort of your own home (assuming you own a 3D printer of course).





Programming the keyboard functions on the Teensy is surprisingly simple. There are great instructions on the Teensy development board page for sending keystrokes to your computer and because the board identifies itself as a USB keyboard it works when plugged into a PC or Mac with no additional software! One note: to use the USB keyboard mode you must use the “Teensyduino” software which allows you to program the Teensy using the Arduino programming language and IDE rather than the native Teensy language. I’ve included the code in full at the bottom of the post, but to give a brief overview, when the upvote button is pressed the key combination “CTRL + SHIFT + A” is sent to the computer over USB, likewise if downvote is pressed “CTRL + SHIFT + Z” is sent to the computer. I defined these keystrokes in the Reddit Enhancement Suite manually because they seemed like a key combination that wouldn’t conflict with other programs (default is “a” and “z”).

Above is a drawing of the circuit I put together for the buttons. As you can see it’s really simple and basically an exact copy of the “Button” example on the Arduino website. I moved the circuit from my breadboard to a scrap of circuit board I had left over from my Arc Reactor project and soldered everything down. Since I was looking to fit this into a pretty small space my tolerances (wire length, etc) were also small. Much to my surprise everything worked on my first attempt to move it to a finished board. The only thing left to do was reconnect the USB cord I snipped in half to fit into my project box and put a couple dabs of hot glue on the lid to keep it closed.





Below is a collection of video clips I took while putting this project together. I think it turned out pretty nice and is a great example of the different ways to change a previous project (yours or in this case, someone else’s the “Awesome Button”) into something to fit your needs.





/* Reddit Upvote/Downvote Button This code sends the keystroke "CTRL + SHIFT + A" or "CTRL + SHIFT + Z" to your PC or Mac. Make sure you set your Arduino compatible board to "Keyboard + Mouse" in the "USB Type" menu. Hotkeys can be changed easily, I've added comments to make it easier to find. For this to work with Reddit as an Upvote/Downvote button you will need to install Reddit Enhancement Suite (http://reddit.honestbleeps.com/) and set your Upvote and Downvote hotkeys to the ones assigned in this Arduino sketch. Code examples edited and reworked from http://wwww.arduino.cc and http://www.pjrc.com/teensy TheNewHobbyist 2011 */ // The inputs you're using for button presses const int upVote = 8; // Upvote const int downVote = 5; // Downvote int upVoteStatus = 0; int downVoteStatus = 0; void setup() { pinMode(upVote, INPUT); pinMode(downVote, INPUT); } void loop(){ // Check the buttons upVoteStatus = digitalRead(upVote); downVoteStatus = digitalRead(downVote); // If Upvote button is pressed if (upVoteStatus == HIGH) { // Change the following two lines to change the keys sent Keyboard.set_modifier(MODIFIERKEY_CTRL | MODIFIERKEY_SHIFT); Keyboard.set_key1(KEY_A); Keyboard.send_now(); Keyboard.set_modifier(0); Keyboard.set_key1(0); Keyboard.send_now(); delay(500); } // If Downvote button is pressed if (downVoteStatus == HIGH) { // Change the following two lines to change the keys sent Keyboard.set_modifier(MODIFIERKEY_CTRL | MODIFIERKEY_SHIFT); Keyboard.set_key1(KEY_Z); Keyboard.send_now(); Keyboard.set_modifier(0); Keyboard.set_key1(0); Keyboard.send_now(); delay(500); } }

[thingiverse thing=10423]