 
     Serial.println();
 
+    // Atomically reset interruption flag.
     ATOMIC_BLOCK(ATOMIC_FORCEON) {
       movementDetected = false;
     }

void loop() {
  bool movDetected = false;

  ATOMIC_BLOCK(ATOMIC_FORCEON) {
    movDetected = movementDetected;
  }

  if(movDetected) {
    int intStatus = imu.getAccelIntGenerator1Status();

    if((intStatus & LSM303D_ZONE_ZH) != 0) {
      Serial.print("Movement on Z: ");
      Serial.print(imu.readAccelZ());
      Serial.println("g");
    }

    if((intStatus & (LSM303D_ZONE_YH | LSM303D_ZONE_YL)) != 0) {
      Serial.print("Movement on Y: ");
      Serial.print(imu.readAccelY());
      Serial.println("g");
    }

    if((intStatus & (LSM303D_ZONE_XH | LSM303D_ZONE_XL)) != 0) {
      Serial.print("Movement on X: ");
      Serial.print(imu.readAccelX());

/**
 * @file InterruptGenerator.ino
 * Example of accelerometer interruptio generator usage.
 * 
 * Copyright (c) 2015 Circuitar
 * This software is released under the MIT license. See the attached LICENSE file for details.
 */
#include <Wire.h>
#include <Nanoshield_IMU.h>
#include <PinChangeInterrupt.h>
