Naresh Krish
/
itracker-mbed-os-example-lis3dh
Sample program on how to use the LIS3DH sensor on the RAKWireless iTracker module
Diff: main.cpp
- Revision:
- 0:cd96b05ace6e
diff -r 000000000000 -r cd96b05ace6e main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Feb 12 05:05:29 2018 +0000 @@ -0,0 +1,20 @@ +#include "mbed.h" +#include "SEGGER_RTT.h" +#include "LIS3DH.h" + +// main() runs in its own thread in the OS +int main() { + I2C i2c(p19,p18); // SDA, SCL + LIS3DH acc(i2c, LIS3DH_V_CHIP_ADDR, LIS3DH_DR_NR_LP_50HZ, LIS3DH_FS_8G); + + + SEGGER_RTT_printf(0, "dev id is %d \n", acc.read_id()); + if (acc.read_id() == I_AM_LIS3DH){ + while(1) { + float f[3]; + acc.read_data(f); + wait(0.5); + } + } +} +