RSS
 

Am I doing this right? (Reddit Upvote Button)

27 Jul


 

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.


 

[thingiverse thing=10423]

 
 
  • http://www.frugalandyoung.com Justin

    That’s very cool. Any chance you would sell these as a kit?

    • chris

      I’ve actually been looking for a reason to get some printed circuit boards made. Depending on interest I could totally see making this a kit. Stay tuned…

  • Adrian

    I believe there’s a bug in the code you posted (more like a spelling mistake).
    You named the variables up/downVoteState in the declaration but you’re using up/downVoteStatus in the IF (State vs Status).

    Cool project

    • chris

      Nice catch, I tried to tidy everything up for easy reading before posting it and it looks like that slipped by me. Thanks!

      • hotdog

        what is this music? its great!

        • chris

          It’s Powerhouse by Raymond Scott. It was used for pretty much any/every cartoon factory scene in Looney Tunes. Classic stuff.

  • http://james-wood.com.au James

    Ha! Nice one. I’m loving the music too!

  • Pingback: USB Reddit Upvote / Downvote butonul | ro-Stire

  • Pingback: USB Reddit Upvote/Downvote button | The Depot of Talk

  • http://www.billporter.info/ Bill Porter

    Any reason you used external pull down resistors instead of the AVR’s internal pull-ups?

    • chris

      Bill,

      I’m still somewhat new to working with Arduino and compatibles. I built my circuit off the “Button” tutorial on Arduino.cc. While it works I’d be willing to try other methods. Is there an advantage of doing it the other way?

      • http://www.billporter.info Bill

        The only advantage is it elminates the resistors and a few wires from your schematic. I think the Arduino example did it with the external resistor just so new beginners don’t get confused. When you use the internal pull-up resistors, you only need one wire to the switch, and a second wire to ground; so when the button is pressed it connects the I/O line to ground. But this mean in your code, LOW = switch pressed and HIGH = not pressed. Which can seem a little backwards, but it works just as well with fewer parts.

        Anyway, welcome to Arduino!

        • http://rasterweb.net/raster/ Pete Prodoehl

          I did the same thing with my first Teensy project… Next time around I got wise to just using the internal pullup resistor.

          Also, great project, thanks for sharing it!

  • randy random

    Hey! This looks really cool. Been using a K8055 myself for small input/output projects. But that board looks fantastic.

    I do have a question, a bit on the side of the project.

    What notebook is that? It seems awesome with the header like that. I always end up writing that stuff down in the top myself.

    • chris

      It’s a Maker’s Notebook from Make Magazine. It has the header and grid as you mentioned and a lot of helpful info in the back pages (resistor key, handy formulas, etc). It also has a pocket in the back like a Moleskine note book. It’s pricey at ~$20 (I got mine as a free gift for ordering way too many items from the Make store) but it’s actually really nice and I’d buy another when I run out of pages.

  • Pingback: Okay, Whatever. » Blog Archive » Google Reader Shared Items 2011-08-04

  • http://twitter.com/myparrotsteeth Jamie

    As the blue Sharpie ink on the downvote arrow wears off over time, yet the red plastic on the upvote arrow remains cheerful and bright, do you worry that people who see your device over the months will become convinced that you’re hating on everything you view on Reddit, since you’ve ‘clearly’ been working it a hell of a lot more? : )

    • chris

      At this point I will be viewed as history’s greatest monster by all my Reddior peers. :(

  • Pingback: Vote Up Button | TechMASH

  • Pingback: Vote Up Button | TechMASH

  • sjking2000

    Instant awesomeness. I want to try this with an instapaper button, send email (Firefox ubiquity) …