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: C12832_lcd CMPS03 GPS MMA7660 mbed
main.cpp
00001 #include "mbed.h" 00002 #include "CMPS03.h"//added 00003 #include "MMA7660.h" 00004 #include "stdio.h" //needed? 00005 #include "GPS.h" 00006 00007 00008 /*THIS FILE IS MADE TO RUN ON THE MBED. IT WILL TAKE ACCELEROMETER VALUES AND WRITE THEM 00009 TO A TEXT FILE AND THEN A CONNECTED COMPUTER*/ 00010 GPS gps(p13, p14);// which pins??? 00011 CMPS03 compass(p9, p10, CMPS03_DEFAULT_I2C_ADDRESS);//added 00012 DigitalOut myled(LED1); 00013 MMA7660 MMA(p28, p27); // Accelerometer connections 00014 float ax, ay, az; //allocations for the x, y, z values 00015 Serial pc(USBTX,USBRX); // serial port 00016 LocalFileSystem local("local"); // Create the local filesystem called "local" 00017 int main() 00018 { 00019 float data[100]; // three data arrays, with 100 entries 00020 float data1[100]; 00021 float data2[100]; 00022 float data3[100]; 00023 00024 00025 for (int i=0; i<100; i++) 00026 { 00027 ax=MMA.x(); //ax is the x value from the accelerometer. the *90 part is to get an angle 00028 data[i] = ax ; //place the value of the accelerometer into the 1st array 00029 ay=MMA.y(); 00030 data1[i] = ay ; 00031 az=MMA.z(); 00032 data2[i] = az; 00033 data3[i] = (compass.readBearing() / 10.0); 00034 00035 00036 wait (0.1);// so all the results aren't taken as quickly as the mbed can process. total time = wait time * number of items in array 00037 } 00038 00039 FILE *fp = fopen("/local/values.txt", "w"); // Open "values.txt" 00040 fprintf(fp,"Location is: %f , %f", gps.longitude, gps.latitude); 00041 for (int i=0; i<100; i++) 00042 { 00043 fprintf(fp,"%i %f %f %f Bearing:%f \r\n ", i, data[i], data1[i], data2[i], data3[i]); //print all the data values to the file 00044 } 00045 fclose(fp); //save and close the file 00046 00047 00048 00049 00050 00051 } 00052 00053 00054
Generated on Fri Jul 15 2022 01:45:41 by
1.7.2