   void updateHeading(){
     /* Get a new sensor event */ 
     sensors_event_t event; 
+    sensors_event_t accel_event;
+    accel.getEvent(&accel_event);
     mag.getEvent(&event);
+    
+//    if(!dof.magTiltCompensation(SENSOR_AXIS_Z, &event, &accel_event)){
+//      return;
+//    }
     
     // Hold the module so that Z is pointing 'up' and you can measure the heading with x&y
     // Calculate heading when the magnetometer is level, then correct for signs of axis.

    mySerial.begin(9600);

    /* Initialise the compass */
    if(!mag.begin()){
      /* There was a problem detecting the HMC5883 ... check your connections */
      Serial.println("Ooops, no HMC5883 detected ... Check your wiring!");
      while(1);
    }
    //Setup test waypoint

#include <TinyGPS.h>  
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303_U.h>
#include <Adafruit_L3GD20_U.h>
#include <Adafruit_9DOF.h>
#include <SabertoothSimplified.h>

// tiny gps library code
