 }
 
 
-//Sends a write command
+//Write to register
 //*****************************************************
 void writeRegister(byte thisRegister, byte thisValue) 
 //*****************************************************

    // We want to sample as rapidly as possible, so that we have the minimum
    // latency between motion and its detection.  Even at 1kHz, we're going to
    // have some fraction of a second of latency on our reads.
    //MPU6000_SPI_write(MPUREG_SMPLRT_DIV,0x04);     // Sample rate = 200Hz    Fsample= 1Khz/(4+1) = 200Hz     
    //writeRegister(MPUREG_SMPLRT_DIV,19);     // Sample rate = 50Hz    Fsample= 1Khz/(19+1) = 50Hz     
    writeRegister(MPUREG_SMPLRT_DIV,0);
    delay(1);

    // Set the filter pass frequency on the low-pass filter to the maximum
    // (no filter, corresponding to a 2.1Khz cutoff).
    //writeRegister(MPUREG_CONFIG, BITS_DLPF_CFG_20HZ);
    writeRegister(MPUREG_CONFIG, BITS_DLPF_CFG_2100HZ_NOLPF);
    delay(1);
    


// pins used for the connection with the sensor
// the other you need are controlled by the SPI library):
const int chipSelectPin = 10;

// Thresholds
const int GYRO_THRESHOLD = 10;
const int ACCEL_CHANGE_THRESHOLD = 10;
const int BRIGHTNESS_CHANGE_THRESHOLD = 10;
const unsigned long TIMEOUT_USEC = 1000000L;

//*****************************************************
void setup() 
//*****************************************************
{
  Serial.begin(9600);
  Serial.print("OSVR_latency_hardware_firmware v01.00\n");
  Serial.print(" Mount the photosensor rigidly on the screen.\n");
  Serial.print(" Move the interial sensor along with the tracking hardware.\n");
  Serial.print(" Make the app change the brightness in front of the photosensor.\n");
  
  MPU6000_Init();
  delay(100);
