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.
main.cpp
00001 #include "mbed.h" 00002 #include "FXOS8700.h" 00003 // Check out the full featured example application for interfacing to 00004 // the Accelerometer/Magnetometer device at the following URL 00005 // https://developer.mbed.org/users/trm/code/fxos8700cq_example// 00006 DigitalOut led1(LED_GREEN); 00007 // Initialize Serial port 00008 Serial pc(USBTX, USBRX); 00009 FXOS8700 accel(PTC11, PTC10); 00010 FXOS8700 mag(PTC11, PTC10); 00011 // main() runs in its own thread in the OS 00012 // (note the calls to Thread::wait below for delays) 00013 int main() { 00014 // Configure Accelerometer FXOS8700, Magnetometer FXOS8700 00015 accel.accel_config(); 00016 mag.mag_config(); 00017 float accel_data[3]; float accel_rms=0.0; 00018 float mag_data[3]; float mag_rms=0.0; 00019 //printf("Begin Data Acquisition from FXOS8700CQ sensor....\r\n\r\n"); 00020 wait(1.5); 00021 while (1) { 00022 led1 = !led1; 00023 // Example data printing 00024 accel.acquire_accel_data_g(accel_data); 00025 accel_rms = sqrt(((accel_data[0]*accel_data[0])+(accel_data[1]*accel_data[1])+(accel_data[2]*accel_data[2]))/3); 00026 printf("%4.2f %4.2f %4.2f\n\r",accel_data[0],accel_data[1],accel_data[2]); 00027 wait(0.01); 00028 //mag.acquire_mag_data_uT(mag_data); 00029 //mag_rms = sqrt(((mag_data[0]*mag_data[0])+(mag_data[1]*mag_data[1])+(mag_data[2]*mag_data[2]))/3); 00030 //printf("Magnetometer \tX-Axis %4.2f \tY-Axis %4.2f \tZ-Axis %4.2f \tRMS %4.2f\n\n\r",mag_data[0],mag_data[1],mag_data[2],mag_rms); 00031 //wait(0.01); 00032 Thread::wait(500); 00033 } 00034 } 00035
Generated on Tue Jul 19 2022 02:05:27 by
1.7.2