Simple gyroscope program example for Hexiwear featuring UART

Dependencies:   FXAS21002

Fork of Hexi_gyro_app by Mac Lobdell

This project demonstrates the use of the FXAS21002CQ Gyroscope sensor embedded in hexiwear

Open a Hyperterminal tool on your computer and connect it to the "mbed Serial port (COMxx)" with Baud rate "9600bps"

Compile the project and copy the binary "Hexi_Gyro_Example_HEXIWEAR.bin" in the DAP-LINK drive from your computer file explorer Press the K64F-RESET button on the docking station to start the program on your board

Every 1s the value of the Gyroscope for the Axis Roll, Pitch and Yaw plus their RMS value will be displayed in the Hyperterminal window and the LED will blink Green

Committer:
maclobdell
Date:
Fri Aug 12 16:25:02 2016 +0000
Revision:
0:b0767be19223
Child:
1:d26e406e92f9
initial;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maclobdell 0:b0767be19223 1 #include "mbed.h"
maclobdell 0:b0767be19223 2 #include "FXAS21002.h"
maclobdell 0:b0767be19223 3
maclobdell 0:b0767be19223 4 /* Check out the full featured example application for interfacing to the
maclobdell 0:b0767be19223 5 * Gyro device at the following URL
maclobdell 0:b0767be19223 6 * https://developer.mbed.org/teams/ATT-Hackathon/code/Accel_Mag_Gyro_SensorStream_K64F_AGM01_M/
maclobdell 0:b0767be19223 7 */
maclobdell 0:b0767be19223 8
maclobdell 0:b0767be19223 9 DigitalOut led1(LED1);
maclobdell 0:b0767be19223 10
maclobdell 0:b0767be19223 11 // Pin connections for Hexiwear
maclobdell 0:b0767be19223 12 FXAS21002 gyro(PTC11,PTC10);
maclobdell 0:b0767be19223 13 // Storage for the data from the sensor
maclobdell 0:b0767be19223 14 float gyro_data[3]; float gyro_rms=0.0;
maclobdell 0:b0767be19223 15
maclobdell 0:b0767be19223 16
maclobdell 0:b0767be19223 17 // main() runs in its own thread in the OS
maclobdell 0:b0767be19223 18 // (note the calls to Thread::wait below for delays)
maclobdell 0:b0767be19223 19 int main() {
maclobdell 0:b0767be19223 20
maclobdell 0:b0767be19223 21 gyro.gyro_config();
maclobdell 0:b0767be19223 22 while (true) {
maclobdell 0:b0767be19223 23
maclobdell 0:b0767be19223 24 gyro.acquire_gyro_data_dps(gyro_data);
maclobdell 0:b0767be19223 25 printf("G %4.2f,\t%4.2f,\t%4.2f\r\n",gyro_data[0],gyro_data[1],gyro_data[2]);
maclobdell 0:b0767be19223 26 gyro_rms = sqrt(((gyro_data[0]*gyro_data[0])+(gyro_data[1]*gyro_data[1])+(gyro_data[2]*gyro_data[2]))/3);
maclobdell 0:b0767be19223 27 printf("G RMS %f \n",gyro_rms);
maclobdell 0:b0767be19223 28
maclobdell 0:b0767be19223 29 led1 = !led1;
maclobdell 0:b0767be19223 30 Thread::wait(1000);
maclobdell 0:b0767be19223 31 }
maclobdell 0:b0767be19223 32 }
maclobdell 0:b0767be19223 33