mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-01 13:00:59 +02:00
Co-authored-by: Jason2866 <24528715+Jason2866@users.noreply.github.com> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com> Co-authored-by: Tomáš Pilný <34927466+PilnyTomas@users.noreply.github.com> Co-authored-by: Pedro Minatel <pedro.minatel@espressif.com> Co-authored-by: Ivan Grokhotkov <ivan@espressif.com> Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net>
28 lines
656 B
C++
28 lines
656 B
C++
#if ARDUINO_USB_MODE
|
|
#warning This sketch should be used when USB is in OTG mode
|
|
void setup(){}
|
|
void loop(){}
|
|
#else
|
|
#include "USB.h"
|
|
#include "USBHIDConsumerControl.h"
|
|
USBHIDConsumerControl ConsumerControl;
|
|
|
|
const int buttonPin = 0;
|
|
int previousButtonState = HIGH;
|
|
|
|
void setup() {
|
|
pinMode(buttonPin, INPUT_PULLUP);
|
|
ConsumerControl.begin();
|
|
USB.begin();
|
|
}
|
|
|
|
void loop() {
|
|
int buttonState = digitalRead(buttonPin);
|
|
if ((buttonState != previousButtonState) && (buttonState == LOW)) {
|
|
ConsumerControl.press(CONSUMER_CONTROL_VOLUME_INCREMENT);
|
|
ConsumerControl.release();
|
|
}
|
|
previousButtonState = buttonState;
|
|
}
|
|
#endif /* ARDUINO_USB_MODE */
|