     Serial.print("   Straight");
 
     delay(1000);
-    
+
     // turn off motors and wait a short time to reduce interference from motors
     motors.setSpeeds(0, 0);
     delay(100);
-    
+
     // We now want to turn 90 degrees relative to the direction we are pointing at.
     // This will help account for variable magnetic field.
     targetHeading = (averageHeading() + 90) % 360;
-  } 
-  else 
+  }
+  else
   {
     if((relHeading - DEVIATE_RIGHT_THRESHOLD) < (DEVIATE_LEFT_THRESHOLD - relHeading))
     {

#include <Wire.h>
#include <LSM303.h>

/* This example uses ZumoMotors, Wire, and LSM303 (compass) library to 
 * drive the Zumo in squares. To do this, the Zumo first calibrates 
 * the compass to account for offsets in its output. Calibration is
 * accomplished in setup().
 *
 * In loop(), The driving angle then changes its offset by 90 degrees 
 * from the heading every second. Essentially, this navigates the
 * Zumo to drive in square patterns.
 *


// Setup will calibrate our compass
// We calibrate by finding maximum/minimum magnetic readings
void setup()
{
  // The highest possible magnetic value to read in any direction is 2047
  // The lowest possible magnetic value to read in any direction is -2047
  LSM303::vector running_min = {2047, 2047, 2047}, running_max = {-2048, -2048, -2048};
  unsigned char index;

  Serial.begin(9600);

  // Initiate the Wire library and join the I2C bus as a master
  Wire.begin();

  // Initiate LSM303
  compass.init();

  // Enables Accelerometer and Magnetometer
  compass.enableDefault();

  compass.setMagGain(compass.magGain_25);                  // +/- 2.5 gauss sensitivity to hopefully avoid overflow problems
  compass.writeMagReg(LSM303_CRA_REG_M, CRA_REG_M_220HZ);  // 220 Hz compass update rate

  float min_x_avg[CALIB_SAMPLES];
  float min_y_avg[CALIB_SAMPLES];
  float max_x_avg[CALIB_SAMPLES];
  float max_y_avg[CALIB_SAMPLES];

  button.waitForButton();

  Serial.println("starting calibration");

  // To calibrate the magnetometer we must spin the Zumo to find the Max/Min
  // magnetic vectors. This information is used to find North and East.
  motors.setLeftSpeed(SPEED);
