Allowed for the choosing the g-range of the accelerometer. Scaling also tracks choice so units and values are correct
Dependents: LCD_punch_mtr_8_v5 LCD_punch_mtr_8_v5
Fork of MMA8451Q by
MMA8451Q Class Reference
MMA8451Q accelerometer example. More...
#include <MMA8451Q8.h>
Public Member Functions | |
MMA8451Q (PinName sda, PinName scl, int addr) | |
MMA8451Q constructor. | |
~MMA8451Q () | |
MMA8451Q destructor. | |
uint8_t | getWhoAmI () |
Get the value of the WHO_AM_I register. | |
float | getAccX () |
Get X axis acceleration. | |
float | getAccY () |
Get Y axis acceleration. | |
float | getAccZ () |
Get Z axis acceleration. | |
void | getAccAllAxis (float *res) |
Get XYZ axis acceleration. | |
void | setGLimit (int gSelect) |
Allow user to set max g's. |
Detailed Description
MMA8451Q accelerometer example.
#include "mbed.h" #include "MMA8451Q.h" #define MMA8451_I2C_ADDRESS (0x1d<<1) int main(void) { MMA8451Q acc(P_E25, P_E24, MMA8451_I2C_ADDRESS); PwmOut rled(LED_RED); PwmOut gled(LED_GREEN); PwmOut bled(LED_BLUE); while (true) { rled = 1.0 - abs(acc.getAccX()); gled = 1.0 - abs(acc.getAccY()); bled = 1.0 - abs(acc.getAccZ()); wait(0.1); } }
Definition at line 49 of file MMA8451Q8.h.
Constructor & Destructor Documentation
MMA8451Q | ( | PinName | sda, |
PinName | scl, | ||
int | addr | ||
) |
MMA8451Q constructor.
- Parameters:
-
sda SDA pin sdl SCL pin addr addr of the I2C peripheral
Definition at line 43 of file MMA8451Q8.cpp.
~MMA8451Q | ( | ) |
MMA8451Q destructor.
Definition at line 49 of file MMA8451Q8.cpp.
Member Function Documentation
void getAccAllAxis | ( | float * | res ) |
Get XYZ axis acceleration.
- Parameters:
-
res array where acceleration data will be stored
Definition at line 80 of file MMA8451Q8.cpp.
float getAccX | ( | ) |
float getAccY | ( | ) |
float getAccZ | ( | ) |
uint8_t getWhoAmI | ( | ) |
Get the value of the WHO_AM_I register.
- Returns:
- WHO_AM_I value
Definition at line 51 of file MMA8451Q8.cpp.
void setGLimit | ( | int | gSelect ) |
Allow user to set max g's.
Definition at line 56 of file MMA8451Q8.cpp.
Generated on Fri Jul 15 2022 00:49:53 by 1.7.2