Skip to content

Instantly share code, notes, and snippets.

@raster
Last active October 4, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raster/2650718 to your computer and use it in GitHub Desktop.
Save raster/2650718 to your computer and use it in GitHub Desktop.
Simple two button control with a Teensy
/*
* TeensyTwoButtons.pde
*
* You must select Keyboard from the "Tools > USB Type" menu
*
* Download and install the Bounce library: http://www.pjrc.com/teensy/td_libs_Bounce.html
*
*/
#include <Bounce.h>
Bounce button0 = Bounce(0, 10);
Bounce button1 = Bounce(1, 10);
void setup() {
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
}
void loop() {
button0.update();
button1.update();
if (button0.fallingEdge()) {
Keyboard.print("-");
}
if (button1.fallingEdge()) {
Keyboard.print("+");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment