An arduino library for the MMA8453 Triple Axis Accelerometer
#include "I2C.h"#include "MMA8453Q.h"MMA8453Q accelerometer;Now get accelerometer readings with the functions getX(), getY(), and getZ(), as in:
int x = accelerometer.getX();The values can be positive or negative and range from -512 to 512. See the entire example sketch below.
#include#include MMA8453Q accelerometer;void setup(){ Serial.begin(9600);} void loop(){ Serial.print("X:"); Serial.print(accelerometer.getX()); Serial.print(", Y:"); Serial.print(accelerometer.getY()); Serial.print(", Z:"); Serial.print(accelerometer.getZ()); Serial.println(); delay(300);}
const byte I2C_ADDR = 0x1C; //SA0=0previously it had been 0x1D. Download the MMA8453Q Accelerometer library from Github!
Comments: