         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;
+        }
       }
     }
   }

    if (stillMillis==0) {
      stillBegin = millis();
      stillMillis = 1;
    }
    else {
      stillMillis = millis() - stillBegin;


// ************* BLE **************************************************
BLEPeripheral blePeripheral;        // BLE Peripheral Device (the board you're programming)
BLEService diceService("0x1812");  // BLE Service
BLEUnsignedCharCharacteristic diceRollCharacteristic("0x2AC5", BLERead|BLEWrite|BLENotify);//20); // payload size
BLEUnsignedCharCharacteristic diceCommandCharacteristic("0x2A9F", BLERead|BLEWrite|BLENotify);

boolean gConnect = false;
//int16_t   diceId = 1;
unsigned char diceId = 1;
uint16_t  seqNum = 0;
uint16_t nextSeqNum() {
  seqNum++;
  return seqNum;
}
bool rollSent = false;

// ************* IMU **************************************************
int16_t vraw[10]; // raw readings from IMU and info for sending via BLE
