Note that the magnetometer is not calibrated, so you'll get different numbers on XYZ but when you twist and rotate the mirobit the numbers should move up and down a bit! (This is why magnetometers must be calibrated)

/*
* MMA845XQ test code
* (C) 2012 Akafugu Corporation
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
*/
#include "Wire.h"
#include "MMA8653.h"
MMA8653 accel;
void setup() {
Serial.begin(9600);
Serial.println("microbit accel test");
accel.begin(false, 2); // 8-bit mode, 2g range
}
void loop() {
accel.update();
Serial.print(accel.getX()); Serial.print(" , ");
Serial.print(accel.getY()); Serial.print(", ");
Serial.println(accel.getZ());
delay(100);
}

/*
* MMA845XQ test code
* (C) 2012 Akafugu Corporation
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
*/
#include "Wire.h"
#include "MMA8653.h"
MMA8653 accel;
void setup() {
Serial.begin(9600);
Serial.println("microbit accel test");
accel.begin(false, 2); // 8-bit mode, 2g range
}
void loop() {
accel.update();
Serial.print(accel.getX()); Serial.print(" , ");
Serial.print(accel.getY()); Serial.print(", ");
Serial.println(accel.getZ());
delay(100);
}

And open the serial monitor to see the X Y and Z acceleration data points!

This library is pretty old and incomplete so at this time you can only use it in 8-bit mode. If you want to get the data in g's use this for the loop:

OUT OF STOCK NOTIFICATION

YOUR NAME

YOUR EMAIL

You have been successfully subscribed to the Notification List for this product and will therefore receive an e-mail from us when it is back in stock!

For security reasons, an e-mail has been sent to you acknowledging your subscription. Please remember that this subscription will not result in you receiving any e-mail from us about anything other than the restocking of this item.

If, for any reason, you would like to unsubscribe from the Notification List for this product you will find details of how to do so in the e-mail that has just been sent to you!