Created
February 23, 2022 09:26
-
-
Save juanalonso/a397704accf0ff42decc32d503220519 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Mando pasadiapositivas (siguiente y anterior) por | |
* bluetooth, usando dos botones del Lolin32 (ESP32) | |
*/ | |
#include <Bounce2.h> | |
#include <BleKeyboard.h> | |
#define PREV_GPIO 4 | |
#define NEXT_GPIO 23 | |
BleKeyboard bleKeyboard("KokuGorro", "Kokuma", 80); | |
bool estadoBoton = HIGH; | |
Bounce2::Button butPREV = Bounce2::Button(); | |
Bounce2::Button butNEXT = Bounce2::Button(); | |
int counter = 0; | |
void setup() { | |
bleKeyboard.begin(); | |
butPREV.attach(PREV_GPIO, INPUT_PULLUP); | |
butPREV.interval(5); | |
butPREV.setPressedState(LOW); | |
butNEXT.attach(NEXT_GPIO, INPUT_PULLUP); | |
butNEXT.interval(5); | |
butNEXT.setPressedState(LOW); | |
pinMode(LED_BUILTIN, OUTPUT); | |
digitalWrite(LED_BUILTIN, LOW); | |
} | |
void loop() { | |
butPREV.update(); | |
butNEXT.update(); | |
if (bleKeyboard.isConnected()) { | |
if (butPREV.pressed()) { | |
bleKeyboard.write(KEY_LEFT_ARROW); | |
} | |
if (butNEXT.pressed()) { | |
bleKeyboard.write(KEY_RIGHT_ARROW); | |
} | |
digitalWrite(LED_BUILTIN, counter > 0); | |
counter = ++counter % 30; | |
} | |
delay(50); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment