forked from espressif/arduino-esp32
Implement USB HID Device Support for ESP32-S2 (#5538)
* Add support and example for USB HID Devices * Add support and example for USB Vendor
This commit is contained in:
0
libraries/USB/examples/ConsumerControl/.skip.esp32
Normal file
0
libraries/USB/examples/ConsumerControl/.skip.esp32
Normal file
21
libraries/USB/examples/ConsumerControl/ConsumerControl.ino
Normal file
21
libraries/USB/examples/ConsumerControl/ConsumerControl.ino
Normal file
@ -0,0 +1,21 @@
|
||||
#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;
|
||||
}
|
Reference in New Issue
Block a user