Hello,
I have this interactive that uses push buttons to control a power point show.
I'm also using a Teensy 2.0.
However I've been having issues with the Keyboard.press(KEY_LEFT_SHIFT); Keyboard.press(KEY_TAB); Keyboard.press(KEY_ENTER); pressing multiple times when the button is pressed. From some research I have found that maybe 'debouncing' it could help but I can't figure out what code to add where to what I currently have. Thanks in advance for your help.
This is the code I currently have:
#include <Bounce.h>
// Define our two buttons. We are using the
// 3rd party "bounce" library to more reliably
// read the button clicks.
//
// Read more:
// https://www.pjrc.com/teensy/td_libs_Bounce.html
Bounce buttonTrue = Bounce(PIN_D4, 10);
Bounce buttonFalse = Bounce(PIN_B1, 10);
// Setup the two buttons with the pins we
// have connected to and make sure to
// make use of the internal pull-up circuitry
void setup() {
pinMode(PIN_D4, INPUT_PULLUP); // True button
pinMode(PIN_B1, INPUT_PULLUP); // False button
pinMode(PIN_D6, OUTPUT); // LED
}
void loop() {
buttonTrue.update();
buttonFalse.update();
[b]
if (buttonTrue.fallingEdge()) {
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.press(KEY_TAB);
Keyboard.press(KEY_ENTER);
}
if (buttonTrue.risingEdge()) {
Keyboard.release(KEY_LEFT_SHIFT);
Keyboard.release(KEY_TAB);
Keyboard.release(KEY_ENTER);[/b]
}
if (buttonFalse.fallingEdge()) {
Keyboard.press(KEY_DOWN_ARROW);
Keyboard.release(KEY_DOWN_ARROW);
delay(100);
Keyboard.press(KEY_DOWN_ARROW);
Keyboard.release(KEY_DOWN_ARROW);
}
if (buttonFalse.risingEdge()) {
Keyboard.release(KEY_DOWN_ARROW);
}
}