-
Notifications
You must be signed in to change notification settings - Fork 518
Open
espressif/arduino-esp32
#7463Description
The following imports conflict with eachother. This is an issue as I would like to use usb and bluetooth keyboards in the same program.
// Bluetooth Libraries
#include <BleKeyboard.h>
// USB Libraries
#include "USB.h"
#include "USBHIDKeyboard.h"
The full program looks somewhat like this
// Bluetooth Libraries
#include <BleKeyboard.h>
BleKeyboard bleKeyboard;
// USB Libraries
#include "USB.h"
#include "USBHIDKeyboard.h"
USBHIDKeyboard Keyboard;
// Button On Board Feather
const int buttonPin = 0;
int buttonState = 0; // variable for reading the pushbutton status
String msg = "Hello Gamer";
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("Starting BLE work!");
bleKeyboard.begin();
Keyboard.begin();
USB.begin();
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
bleKeyboard.setBatteryLevel(98);
buttonState = digitalRead(buttonPin);
// Serial.println("checking button");
// Serial.println(buttonState == LOW);
if (buttonState == LOW){
if(bleKeyboard.isConnected()) {
Serial.println("Using Bluetooth");
bleKeyboard.print(msg);
}
else {
Serial.println("Using USB");
Keyboard.print(msg);
}
delay(500);
}
delay(10);
}
Metadata
Metadata
Assignees
Labels
No labels