
Simple gyroscope program example for Hexiwear featuring UART
Dependencies: FXAS21002
Fork of Hexi_gyro_app by
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
Revision 1:d26e406e92f9, committed 2016-08-15
- Comitter:
- GregC
- Date:
- Mon Aug 15 23:33:04 2016 +0000
- Parent:
- 0:b0767be19223
- Commit message:
- Gyroscope program example for Hexiwear
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r b0767be19223 -r d26e406e92f9 main.cpp --- a/main.cpp Fri Aug 12 16:25:02 2016 +0000 +++ b/main.cpp Mon Aug 15 23:33:04 2016 +0000 @@ -6,7 +6,8 @@ * https://developer.mbed.org/teams/ATT-Hackathon/code/Accel_Mag_Gyro_SensorStream_K64F_AGM01_M/ */ -DigitalOut led1(LED1); +DigitalOut led1(LED_GREEN); +Serial pc(USBTX, USBRX); // Pin connections for Hexiwear FXAS21002 gyro(PTC11,PTC10); @@ -22,9 +23,9 @@ 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]); + pc.printf("Roll (G) %4.2f,\t Pitch (G) %4.2f,\t Yaw (G) %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); + pc.printf("Gyroscope RMS %f \r\n\n",gyro_rms); led1 = !led1; Thread::wait(1000);