Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MMA8491Q by
MMA8491Q Class Reference
MMA8491Q accelerometer example. More...
#include <MMA8491Q.h>
Public Member Functions | |
| MMA8491Q (PinName sda, PinName scl, int addr, PinName en) | |
| MMA8491Q constructor. | |
| ~MMA8491Q () | |
| MMA8491Q destructor. | |
| float | getAccX () |
| Get X axis acceleration. | |
| float | getAccY () |
| Get Y axis acceleration. | |
| float | getAccZ () |
| Get Z axis acceleration. | |
| uint8_t | getAccAllAxis (float *res) |
| Get XYZ axis acceleration. | |
Detailed Description
MMA8491Q accelerometer example.
#include "mbed.h" #include "MMA8491Q.h" #define MMA8451_I2C_ADDRESS (0x55<<1) Serial pc(USBTX, USBRX); int main(void) { MMA8491Q acc(PTE0, PTE1, MMA8451_I2C_ADDRESS, PTA13); PwmOut rled(LED_RED); PwmOut gled(LED_GREEN); PwmOut bled(LED_BLUE); float accData[3]; while (true) { acc.getAccAllAxis(accData); accX = accData[0]; accY = accData[1]; accZ = accData[2]; pc.printf("X = %5.3f", accX); pc.printf(" Y = %5.3f", accY); pc.printf(" Z = %5.3f\r\n", accZ); wait(1.0); } *}
Definition at line 62 of file MMA8491Q.h.
Constructor & Destructor Documentation
| MMA8491Q | ( | PinName | sda, |
| PinName | scl, | ||
| int | addr, | ||
| PinName | en | ||
| ) |
MMA8491Q constructor.
- Parameters:
-
sda SDA pin sdl SCL pin addr addr of the I2C peripheral en EN pin Xout digital output pin Yout digital output pin Zout digital output pin
Definition at line 33 of file MMA8491Q.cpp.
| ~MMA8491Q | ( | ) |
MMA8491Q destructor.
Definition at line 43 of file MMA8491Q.cpp.
Member Function Documentation
| uint8_t getAccAllAxis | ( | float * | res ) |
Get XYZ axis acceleration.
- Parameters:
-
res array where acceleration data will be stored
- Returns:
- true if sensor was ready and data was read
Definition at line 96 of file MMA8491Q.cpp.
| float getAccX | ( | ) |
| float getAccY | ( | ) |
| float getAccZ | ( | ) |
Generated on Thu Jul 14 2022 01:36:16 by
1.7.2
