Accelerometer and angle meter
MMA8452 Class Reference
Library for interfacing with MMA8452 I2C Accelerometer. More...
#include <MMA8452.h>
Public Member Functions | |
MMA8452 (PinName sdaPin, PinName sclPin) | |
Create a MMA8452 object connected to the specified pins. | |
void | init () |
Initialise accelerometer. | |
Acceleration | readValues () |
Get values of acceleration. |
Detailed Description
Library for interfacing with MMA8452 I2C Accelerometer.
- See also:
- http://www.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf
- https://www.sparkfun.com/products/12756
Revision 1.0
- Date:
- March 2015
Example:
#include "mbed.h" #include "MMA8452.h" MMA8452 mma8452(p28,p27); // SDA, SCL Serial serial(USBTX,USBRX); int main() { mma8452.init(); // 100 Hz update rate, ±4g scale Acceleration acceleration; // Accleration structure declared in MMA8452 class while(1) { acceleration = mma8452.readValues(); // read current values and print over serial port serial.printf("x = %.2f g y = %.2f g z = %.2f g\n",acceleration.x,acceleration.y,acceleration.z); wait(0.1); // short delay until next reading } }
Definition at line 68 of file MMA8452.h.
Constructor & Destructor Documentation
MMA8452 | ( | PinName | sdaPin, |
PinName | sclPin | ||
) |
Member Function Documentation
void init | ( | ) |
Generated on Tue Jul 19 2022 21:33:49 by 1.7.2