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:
- 1:ecfba4d67833
- Parent:
- 0:cb663f737aa9
- Child:
- 2:22c3ec6319ce
File content as of revision 1:ecfba4d67833:
#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()
{
MMA8491Q acc(PTE0, PTE1, MMA8491_I2C_ADDRESS);
while (true) {
rled = 1.0 - abs(acc.getAccX());
gled = 1.0 - abs(acc.getAccY());
bled = 1.0 - abs(acc.getAccZ());
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);
// }
//}
}