The MMA8452Q is a tiny and low-power three-axis accelerometer. This library implements a simple interface to access most of the accelerometer functionality from an Arduino.
- Normal and fast raw axes values reading
- Scale configuration (allowed 2g, 4g and 8g scales)
- Custom offset calibration
- Low noise mode
- Orientation detection (portrait/landscape and back/front)
- Auto-WAKE/SLEEP mode and detection
#include <MMA8452Q.h>
#include <Wire.h> /* so the Arduino IDE auto-detects the dependency */
MMA8452Q accel;
int axes[3];
void setup() {
Serial.begin(9600);
if (accel.begin())
while (1); /* error */
}
void loop() {
/* get and print raw axes values */
accel.axes(axes);
Serial.print("x: ");
Serial.print(axes[0]);
Serial.print(", y: ");
Serial.print(axes[1]);
Serial.print(", z: ");
Serial.println(axes[2]);
delay(1000);
}
See the API reference for more information.
- Motion and freefall detection
- Single and double tap detection
- Interrupts configuration
The only dependency is the standard Wire Arduino library.
Just clone the repository into your user libraries directory.
For more info, have a look at the Arduino guide page.
Copyright (C) 2013 Alessandro Ghedini <[email protected]>
See COPYING for the license.