     // clear bond store data
     bleHIDPeripheral.clearBondStoreData();
   }
+  
+  encoder.write(0);
+  
+#ifdef ANDROID_CENTRAL
+  bleHIDPeripheral.setReportIdOffset(1);
+#endif
   
   bleHIDPeripheral.setLocalName("HID Volume");
   bleHIDPeripheral.addHID(bleMultimedia);

  }
}

//
// Based off of: http://www.circuitsathome.com/mcu/programming/reading-rotary-encoder-on-arduino
//

int8_t encStates[] = { 0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0 };
uint8_t oldAB = 0;

int8_t readEncoder()
{
  oldAB <<= 1;
  oldAB |= digitalRead(ENC_A_PIN);
  
  oldAB <<= 1;
  oldAB |= digitalRead(ENC_B_PIN);
  
  return ( encStates[( oldAB & 0x0f )]);
}


#include <BLEHIDPeripheral.h>
#include <BLEMultimedia.h>

// http://www.pjrc.com/teensy/td_libs_Encoder.html
#include <Encoder.h>

// define pins (varies per shield/board)
#define BLE_REQ   10
#define BLE_RDY   2
#define BLE_RST   9

#define BUTTON_PIN 5

#define ENC_RIGHT_PIN 3
#define ENC_LEFT_PIN  4

//#define ANDROID_CENTRAL

BLEHIDPeripheral bleHIDPeripheral = BLEHIDPeripheral(BLE_REQ, BLE_RDY, BLE_RST);
BLEMultimedia bleMultimedia;

Encoder encoder(ENC_RIGHT_PIN, ENC_LEFT_PIN);

int buttonState;

void setup() {
  Serial.begin(115200);

  pinMode(BUTTON_PIN, INPUT_PULLUP);
  buttonState = digitalRead(BUTTON_PIN);

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