Demo of the IKS01A1 - accelerometers
Dependencies: X_NUCLEO_IKS01A1-f255a2c75ecb-14ddc33717d5
main.cpp
- Committer:
- noutram
- Date:
- 2018-06-26
- Revision:
- 0:1882e480b627
File content as of revision 0:1882e480b627:
#include "mbed.h"
#include "x_nucleo_iks01a1.h"
//Onboard LED for indication purposes
DigitalOut led1(LED1);
// Inertial & Environmental expansion board singleton instance
static X_NUCLEO_IKS01A1 *expansion_board = X_NUCLEO_IKS01A1::Instance();
int32_t xyz[3];
// main() runs in its own thread in the OS
int main() {
MotionSensor *acc = expansion_board->GetAccelerometer();
while (true) {
//Indicator
led1 = !led1;
wait(0.5);
//This is NOT interrupt safe
acc->Get_X_Axes(xyz);
//Display on the terminal
int32_t x = xyz[0];
int32_t y = xyz[1];
int32_t z = xyz[2];
printf("x=%d\ty=%d\tz=%d\n\r",x,y,z);
}
}