![](/media/cache/group/IMG_1289.JPG.50x50_q85.jpg)
Test program for MMA8451Q
main.cpp
- Committer:
- Rhyme
- Date:
- 2015-12-25
- Revision:
- 0:b9f8aeb1c46b
- Child:
- 1:61ac5dab9c3e
File content as of revision 0:b9f8aeb1c46b:
#include "mbed.h" #include "MMA8451Q.h" #include "MSS.h" MMA8451Q *acc = 0 ; int main() { int16_t ix, iy, iz ; float fx, fy, fz ; #if 1 // for FRDM-KL25Z ONBOARDSENSOR acc = new MMA8451Q(PTE25, PTE24, 0x1D) ; #endif #if 0 // for MSU MMA8451Q on MSS acc = new MMA8451Q(PIN_SDA, PIN_SCL, 0x1C) ; #endif while(1) { ix = acc->getRawX() ; iy = acc->getRawY() ; iz = acc->getRawZ() ; fx = acc->getAccX() ; fy = acc->getAccY() ; fz = acc->getAccZ() ; printf("X = %d [ %.2f ], Y = %d [ %.2f ], Z = %d [ %.2f ]\n", ix, fx, iy, fy, iz, fz ) ; wait(0.2) ; } }