 }
 
 void loop() {
-  
+  controlMotor();
+  getData();
+  isUsbConnected();
+}
+
+void controlMotor() {
   // Is the motor on? If so, has it been on for more time than motorOn?
   // Is the motorCommand still ON or has it been turned off by other logic?
   // If all true, then turn off the motor and record the time.

    digitalWrite(motorPin, motorState);
    motorPulse = motorCount;
  }
  
  if (serialStream.available()) {
    serialStream.skip();
  }

  shiftOut(dataPin, clockPin, LSBFIRST, i);  
  //take the latch pin high so the LEDs will light up:
  digitalWrite(latchPin, HIGH);
}

void isUsbConnected() {
  // 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]);
      delay(50);
    }
  }
}
