#include #include BleKeyboard bleKeyboard; const int SW1 = 4; const int SW2 = 3; const int LED_PIN = 5; volatile byte state = LOW; void setup() { pinMode(LED_PIN, OUTPUT); pinMode(SW1, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(SW1), setledhigh, FALLING); pinMode(SW2, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(SW2), setledlow, FALLING); Serial.begin(115200); Serial.println("Starting BLE work!"); bleKeyboard.begin(); } void loop() { if(bleKeyboard.isConnected()) { /* Serial.println("Sending 'Hello world'..."); bleKeyboard.print("Hello world"); delay(1000); Serial.println("Sending Enter key..."); bleKeyboard.write(KEY_RETURN); delay(1000); Serial.println("Sending Play/Pause media key..."); bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE); */ delay(1000); // // Below is an example of pressing multiple keyboard modifiers // which by default is commented out. /* Serial.println("Sending Ctrl+Alt+Delete..."); bleKeyboard.press(KEY_LEFT_CTRL); bleKeyboard.press(KEY_LEFT_ALT); bleKeyboard.press(KEY_DELETE); delay(100); bleKeyboard.releaseAll(); */ } Serial.println("Waiting 5 seconds..."); delay(5000); } void setledhigh(){ digitalWrite(LED_PIN, HIGH); if(bleKeyboard.isConnected()) { bleKeyboard.write(KEY_MEDIA_VOLUME_UP); bleKeyboard.print("4"); } Serial.println("Pressed pin 4"); } void setledlow(){ digitalWrite(LED_PIN, LOW); if(bleKeyboard.isConnected()) { bleKeyboard.write(KEY_MEDIA_VOLUME_DOWN); bleKeyboard.print("3"); } Serial.println("Pressed pin 3"); }