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
Revision 3:3f5c717835c3, committed 2013-11-29
- Comitter:
- DiyGuy
- Date:
- Fri Nov 29 23:14:21 2013 +0000
- Parent:
- 2:b79d19bdfe10
- Commit message:
- Added main() example and exercises sensor EN input to trigger new readings
Changed in this revision
MMA8491Q.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MMA8491Q.h Fri Nov 29 23:07:17 2013 +0000 +++ b/MMA8491Q.h Fri Nov 29 23:14:21 2013 +0000 @@ -28,24 +28,37 @@ * #include "mbed.h" * #include "MMA8491Q.h" * -* #define MMA8451_I2C_ADDRESS (0x1d<<1) +* #define MMA8451_I2C_ADDRESS (0x55<<1) +* +* Serial pc(USBTX, USBRX); * * int main(void) { * -* MMA8491Q acc(P_E25, P_E24, MMA8491_I2C_ADDRESS); -* PwmOut rled(LED_RED); -* PwmOut gled(LED_GREEN); -* PwmOut bled(LED_BLUE); +* 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); * -* while (true) { -* rled = 1.0 - abs(acc.getAccX()); -* gled = 1.0 - abs(acc.getAccY()); -* bled = 1.0 - abs(acc.getAccZ()); -* wait(0.1); -* } -* } +* wait(1.0); +* } +*} +* * @endcode */ + class MMA8491Q { public: