         int a = vraw[0]>>8;
         int b = vraw[1]>>8;
         int c = vraw[2]>>8;
-        if (a>0x1d && a<0x3d && b>-10 && b<13 && c>0x12 && c<0x32) dispLed(0x1,0x0f0, 30);
-        else if (a>0x13 && a<0x37 && b>-13 && b<13 && c>(signed char)0xb3 && c<(signed char)0xd6) dispLed(0x3, 0x0f0, 30);
-        else if (a>(signed char)0xee && a<10 && b>(signed char)0xb1 && b<(signed char)0xd1 && c>(signed char)0xe6 && c<10) dispLed(0x7, 0x0f0, 30);
-        else if (a>(signed char)0xed && a<10 && b>0x30 && b<0x50 && c>(signed char)0xeb && c<10) dispLed(0x17, 0x0f0, 30);
-        else if (a>(signed char)0xc5 && a<(signed char)0xe0 && b>-10 && b<10 && c>0x1a && c<0x36) dispLed(0x37, 0x0f0, 30);
-        else if (a>(signed char)0xbb && a<(signed char)0xdb && b>-10 && b<10 && c>(signed char)0xbb && c<(signed char)0xdb) dispLed(0x77, 0x0f0, 30);
+        unsigned char roll=0;
+        if (a>0x1d && a<0x3d && b>-10 && b<13 && c>0x12 && c<0x32)
+          {roll=1; dispLed(0x1,0x0f0, 30);}
+        else if (a>0x13 && a<0x37 && b>-13 && b<13 && c>(signed char)0xb3 && c<(signed char)0xd6)
+          {roll=2; dispLed(0x3, 0x0f0, 30);}
+        else if (a>(signed char)0xee && a<10 && b>(signed char)0xb1 && b<(signed char)0xd1 && c>(signed char)0xe6 && c<10)
+          {roll=3; dispLed(0x7, 0x0f0, 30);}
+        else if (a>(signed char)0xed && a<10 && b>0x30 && b<0x50 && c>(signed char)0xeb && c<10)
+          {roll=4; dispLed(0x17, 0x0f0, 30);}
+        else if (a>(signed char)0xc5 && a<(signed char)0xe0 && b>-10 && b<10 && c>0x1a && c<0x36)
+          {roll=5; dispLed(0x37, 0x0f0, 30);}
+        else if (a>(signed char)0xbb && a<(signed char)0xdb && b>-10 && b<10 && c>(signed char)0xbb && c<(signed char)0xdb)
+          {roll=6; dispLed(0x77, 0x0f0, 30);}
+        if (roll!=0 && !rollSent)
+        {
+          diceRollCharacteristic.setValue((diceId << 4) | roll);
+          rollSent = true;
+        }
       }
     }
   }


void disconnectHandler(BLECentral& central)
{
  SERIAL_PRINT("Disconnected from central: ");
  gConnect = false;
  digitalWrite(13, LOW);  
}

void loop() {


  imuRead();
    
  //if (gConnect) {
  //  SERIAL_PRINT("Sending: ");
  //  vraw[6] = (int16_t) movement;
  //  int16_t stillDur = (stillMillis>32000)? 32000 : stillMillis;
  //  vraw[7] = stillDur;
  //  vraw[8] = diceId;
  //  vraw[9] = nextSeqNum();
  //  diceRollCharacteristic.setValue((unsigned char*) vraw, 20);
  //}

  delay(50);
  if ((millis()-ledLapse) > 1000) {
    ledLapse = millis();
    ledState = !ledState;
