Mac Lobdell
/
Hexi_gyro_app
initial simple example that prints to terminal
main.cpp
- Committer:
- maclobdell
- Date:
- 2016-08-12
- Revision:
- 0:b0767be19223
File content as of revision 0:b0767be19223:
#include "mbed.h" #include "FXAS21002.h" /* Check out the full featured example application for interfacing to the * Gyro device at the following URL * https://developer.mbed.org/teams/ATT-Hackathon/code/Accel_Mag_Gyro_SensorStream_K64F_AGM01_M/ */ DigitalOut led1(LED1); // Pin connections for Hexiwear FXAS21002 gyro(PTC11,PTC10); // Storage for the data from the sensor float gyro_data[3]; float gyro_rms=0.0; // main() runs in its own thread in the OS // (note the calls to Thread::wait below for delays) int main() { gyro.gyro_config(); while (true) { gyro.acquire_gyro_data_dps(gyro_data); printf("G %4.2f,\t%4.2f,\t%4.2f\r\n",gyro_data[0],gyro_data[1],gyro_data[2]); gyro_rms = sqrt(((gyro_data[0]*gyro_data[0])+(gyro_data[1]*gyro_data[1])+(gyro_data[2]*gyro_data[2]))/3); printf("G RMS %f \n",gyro_rms); led1 = !led1; Thread::wait(1000); } }