        << bcd << now.seconds << ' '
        << AnalogPin::bandgap(1100) << PSTR(" mV");
 
+#if defined(__ARDUINO_MEGA__)
+  // Read the heading, scale to milli gauss and print the data
+  compass.read_heading();
+  compass.to_milli_gauss();
+  HMC5883L::data_t dir;
+  compass.get_heading(dir);
+  lcd.set_cursor(0, 2);
+  cout << dir.x << PSTR(", ") << dir.y << PSTR(", ") << dir.z << PSTR(" mG");
+
+  // Read the accelerometer and print the data
+  ADXL345::sample_t acc;
+  accelerometer.sample(acc);
+  lcd.set_cursor(0, 3);
+  cout << acc.x << PSTR(", ") << acc.y << PSTR(", ") << acc.z << PSTR(" mg");
+#endif
+
   // Take a nap
   SLEEP(1);
 }

  // Update the LCD with the reading
  cout << clear;

  // First line with date and temperature
  cout << PSTR("20") << bcd << now.year << '-'
       << bcd << now.month << '-'
       << bcd << now.date << PSTR("  ")
       << (temp >> 2) << PSTR(" C");

  // Second line with time and battery status

  now.year = 0x13;
  rtc.set_time(now);
#endif

#if defined(__ARDUINO_MEGA__)
  // Start the accelerometer with the default settings
  accelerometer.begin();

  // Set continous measurement mode, 3 Hz output, avg 8 samples, +-4.0 Gauss
  compass.set_output_rate(HMC5883L::OUTPUT_RATE_3_HZ);
  compass.set_samples_avg(HMC5883L::SAMPLES_AVG_8);
  compass.set_range(HMC5883L::RANGE_4_0_GA);
  compass.set_mode(HMC5883L::CONTINOUS_MEASUREMENT_MODE);

  // And start the compass
  compass.begin();
#endif

  // Give the sensors some time for startup
  SLEEP(1);
}

void loop()
