
ACELEROMETRO
Fork of FRDM_MMA8451Q by
Revision 10:f47367a7e985, committed 2015-06-23
- Comitter:
- diegovolpini
- Date:
- Tue Jun 23 01:11:35 2015 +0000
- Parent:
- 9:d4bffe27a7bf
- Commit message:
- ACELEROMETRO_TESTE
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jul 16 10:30:54 2014 +0000 +++ b/main.cpp Tue Jun 23 01:11:35 2015 +0000 @@ -19,21 +19,21 @@ int main(void) { MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); - PwmOut rled(LED1); - PwmOut gled(LED2); - PwmOut bled(LED3); - - printf("MMA8451 ID: %d\n", acc.getWhoAmI()); + +Serial pc(USBTX, USBRX); + pc.printf("MMA8451 ID: %d\n\n", acc.getWhoAmI()); while (true) { float x, y, z; - x = abs(acc.getAccX()); - y = abs(acc.getAccY()); - z = abs(acc.getAccZ()); - rled = 1.0f - x; - gled = 1.0f - y; - bled = 1.0f - z; - wait(0.1f); - printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", x, y, z); + x = acc.getAccX(); + y = acc.getAccY(); + z = acc.getAccZ(); + + pc.printf("X:%f ", x); + pc.printf("Y:%f ", y); + pc.printf("Z:%f \n", z); + + wait(2); + } }