 
     while (bleHIDPeripheral.connected()) {
       pollButton();
-      
+
       pollEncoder();
     }
 

void pollEncoder() {
  // check the encoder
  int encoderState = encoder.read();
  
  if (encoderState != 0) {
      if (encoderState > 0) {
        Serial.println(F("Volume up"));
        bleMultimedia.write(MMKEY_VOL_UP);
      } else {
        Serial.println(F("Volume down"));
        bleMultimedia.write(MMKEY_VOL_DOWN);
      }
    
    encoder.write(0);
  }
}




  if (buttonState == LOW) {
    Serial.println(F("BLE HID Peripheral - clearing bond data"));

    // clear bond store data
    bleHIDPeripheral.clearBondStoreData();
  }

  encoder.write(0);

#ifdef ANDROID_CENTRAL
  bleHIDPeripheral.setReportIdOffset(1);
#endif

  bleHIDPeripheral.setLocalName("HID Volume");
  bleHIDPeripheral.addHID(bleMultimedia);

