3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.


Reddit Controller, USB Upvote/Downvote button

Step 4Teensy 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);
}
}
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
47
Followers
6
Author:TheNewHobbyist(The New Hobbyist)