loading
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.

Step 1: Makerbotting a Project Box

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).

Step 2: Circuit Design and Teensy Programming

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.

Step 3: Video Demo Time!


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.


Step 4: Teensy Code

Below is the code I used on my Teensy. It's pretty easy to modify to fit your needs. You can find more information on this project at my blog http://thenewhobbyist.com


/*

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 <http://www.thenewhobbyist.com>

*/

// 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);
}
}
<p>You may want to consider adding some debounce scripts. Check out the button debounce example in the Arduino IDE. This prevents the Teensy from thinking that the &quot;noise&quot; from a button being pressed is multiple presses.</p>
<p>&uarr; Have an upvote!</p>
<p>This is amazing :P I might have found this 3 years later, but its still just awesome!</p>
what is it doing at the end of the video<br>
Up and down voting. :P look at the top left corner of the webstie <br>
upvoting and downvoting on a submission to reddit, i/e what it is supposed to do....
*upvotes* :D
You're a Mac user? You're awesome :)
Put this on reddit and I will give you upvotes. Great job
Me too. Upvotes unquestionably. Link and receive.
Thanks guys, I posted it to /r/DIY here:<br>http://www.reddit.com/r/DIY/comments/j38np/i_made_a_reddit_remote_for_my_desk_upvote_and/<br><br>The link on /r/reddit.com never really took off. Repost it yourself and share in the upvotes!
Ever think of making these to sell? I'd buy it for my guy.
this is excelent and many other uses than just reddit. excelent project box as well

About This Instructable

36,788views

109favorites

License:

More by TheNewHobbyist:Customizable 3D Printable Jack-O-Lantern Doctor WHOokies Arduino powered Haunted Mansion Singing Busts 
Add instructable to: