Playing around with accelerometer and magnetometer on mbed KL46Z
Dependencies: MAG3110 MMA8451Q PinDetect mbed TSI
Diff: main.cpp
- Revision:
- 3:552b7c450b2f
- Parent:
- 2:bb31f097af0f
- Child:
- 4:0d2eefc2be8e
--- a/main.cpp Mon Feb 03 00:19:59 2014 +0000 +++ b/main.cpp Mon Feb 03 01:05:40 2014 +0000 @@ -29,6 +29,13 @@ float xLight; float xTouch; +// Sampling rates +float accRate = 0.5; +float magRate = 0.75; +float lightRate = 0.1; +float touchRate = 0.1; + + // Declare Accelerometer pins and I2C address MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS, 0, 0); // Declare Magnetometer pins @@ -48,10 +55,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, accRate); + timerMag.attach(&magTime, magRate); + timerLight.attach(&lightTime, lightRate); + timerTouch.attach(&touchTime, touchRate); ledred = 0; ledgreen = 0; }