Play around with the xtrinsic sensors package available through Element14. Includes the MAG3110,MMA8491Q and MPL3115.
Dependencies: MAG3110 MMA8491 MMA8491Q MPL3115 MPL3115A2 mbed
main.cpp
- Committer:
- seanburford
- Date:
- 2017-09-14
- Revision:
- 2:22c3ec6319ce
- Parent:
- 1:ecfba4d67833
File content as of revision 2:22c3ec6319ce:
#include "mbed.h" #include "MAG3110.h" #include "MMA8491.h" #include "MMA8491Q.h" #include "MPL3115.h" PwmOut rled(LED_RED); PwmOut gled(LED_GREEN); PwmOut bled(LED_BLUE); int main() { MMA8491 acc(I2C_SDA, I2C_SCL, PTA13); while (true) { float data[3]; acc.acquire_MMA8491_data_g(data); rled = 1.0 - abs((long)data[0]); gled = 1.0 - abs((long)data[1]); bled = 1.0 - abs((long)data[2]); wait(0.1); } //while (true) { // for (float i = 0.0f; i < 1.0f ; i += 0.001f) { // float p = 3 * i; // rled = 1.0f - ((p < 1.0f) ? 1.0f - p : (p > 2.0f) ? p - 2.0f : 0.0f); // gled = 1.0f - ((p < 1.0f) ? p : (p > 2.0f) ? 0.0f : 2.0f - p); // wait (0.0025f); // } //} }