![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Playing around with accelerometer and magnetometer on mbed KL46Z
Dependencies: MAG3110 MMA8451Q PinDetect mbed TSI
Diff: main.cpp
- Revision:
- 5:4ccda4b4f345
- Parent:
- 2:bb31f097af0f
- Child:
- 6:52474f03f1ff
- Child:
- 7:1cd1e239acf0
--- a/main.cpp Mon Feb 03 00:19:59 2014 +0000 +++ b/main.cpp Mon Feb 03 05:38:17 2014 +0000 @@ -48,10 +48,10 @@ void init() { // Attach timerAcc - timerAcc.attach(&accTime, 0.5); - timerMag.attach(&magTime, 0.75); - timerLight.attach(&lightTime, 0.5); - timerTouch.attach(&touchTime, 0.5); + timerAcc.attach(&accTime, 0.05); + timerMag.attach(&magTime, 0.05); + timerLight.attach(&lightTime, 0.05); + timerTouch.attach(&touchTime, 0.05); ledred = 0; ledgreen = 0; } @@ -63,17 +63,9 @@ while(1) { - // Read and print data from accelerometer - pc.puts("Accelerometer: "); - pc.printf("X: %f, Y: %f, Z: %f\t", xAcc, yAcc, zAcc); - // Read data from magnetometer - pc.puts("Magnetometer: "); - pc.printf("X: %d, Y: %d, Z: %d\t", xMag, yMag, zMag); - pc.puts("Light: "); - pc.printf(" %f\t", xLight); - pc.puts("touch: "); - pc.printf(" %f\r\n", xTouch); - wait(0.5); + // read all sensor data + pc.printf("%f %f %f %d %d %d %f %f\n", xAcc, yAcc, zAcc, xMag, yMag, zMag, xLight, xTouch); + wait(0.05); } }