show 3 axis acceleration, temperature, pressure using FRDM-FXS-MULTI and Nucleo board
Dependencies: FXLS8471Q MPL3115A2 mbed
Diff: main.cpp
- Revision:
- 0:e1ad8f9e23e3
- Child:
- 1:edc801915c28
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 28 17:23:50 2014 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" +#include "FXLS8471Q.h" +#include "MPL3115A2.h" + +#define MPL3115A2_I2C_ADDRESS (0x60<<1) + +int main() { + // accelerometer + FXLS8471Q acc(D11, D12, D13, D10); + float acc_data[3]; + + // temperature/pressure sensor + MPL3115A2 tmp(D14, D15, MPL3115A2_I2C_ADDRESS, D3, D4); + tmp.Barometric_Mode(); + + while (true) { + acc.ReadXYZ(acc_data); + printf("x: %1.4f g\ty: %1.4f g\tz: %1.4f g\r\n", acc_data[0], acc_data[1], acc_data[2]); + + printf("temperature: %f C\tpressure: %f Pa\r\n", tmp.getTemperature(), tmp.getPressure()); + + wait(2); + } + + return 0; +} \ No newline at end of file