     }
   }
   
+  // If the motor has been on for time = motorOn and the motorCommand
+  // has been switched to false, then turn off the motor, stop the haptic
+  // feedback and reset the motorPulse to the original motorCount.
   if ((millis()-time) >= motorOn && !motorCommand) {
     motorState = LOW;
     digitalWrite(motorPin, motorState);


void loop() {
  
  //handle motor control
  if (motorState == HIGH && (millis() - time) >= motorOn && motorCommand) {
    motorState = LOW;
    digitalWrite(motorPin, motorState);
    time = millis();
  }
  
  if (motorState == LOW && (millis() - time) >= motorOff 
                          && motorPulse > 0 && motorCommand) {
    motorState = HIGH;

    aJson.deleteItem(msg);
  }
  
  // Until USB has been connected, display a spinning wheel on
  // the 7 segment display.
  if (!usbConnected) {
    for (int c = 0; c < 6; c++) {
      sendDigit(circle[c]);
