Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FXAS21002
Fork of Hexi_gyro_app by
main.cpp
00001 #include "mbed.h" 00002 #include "FXAS21002.h" 00003 00004 /* Check out the full featured example application for interfacing to the 00005 * Gyro device at the following URL 00006 * https://developer.mbed.org/teams/ATT-Hackathon/code/Accel_Mag_Gyro_SensorStream_K64F_AGM01_M/ 00007 */ 00008 00009 DigitalOut led1(LED_GREEN); 00010 Serial pc(USBTX, USBRX); 00011 00012 // Pin connections for Hexiwear 00013 FXAS21002 gyro(PTC11,PTC10); 00014 // Storage for the data from the sensor 00015 float gyro_data[3]; float gyro_rms=0.0; 00016 00017 00018 // main() runs in its own thread in the OS 00019 // (note the calls to Thread::wait below for delays) 00020 int main() { 00021 00022 gyro.gyro_config(); 00023 while (true) { 00024 00025 gyro.acquire_gyro_data_dps(gyro_data); 00026 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]); 00027 gyro_rms = sqrt(((gyro_data[0]*gyro_data[0])+(gyro_data[1]*gyro_data[1])+(gyro_data[2]*gyro_data[2]))/3); 00028 pc.printf("Gyroscope RMS %f \r\n\n",gyro_rms); 00029 00030 led1 = !led1; 00031 Thread::wait(1000); 00032 } 00033 } 00034
Generated on Sun Jul 17 2022 01:00:17 by
1.7.2
