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 "BMP085.h" 00003 #include "string.h" 00004 00005 BMP085 bmp085(p9, p10); 00006 00007 DigitalOut myled(LED1); 00008 DigitalOut myled4(LED4); 00009 Serial pc(USBTX, USBRX); 00010 00011 LocalFileSystem local("local"); 00012 00013 int main() { 00014 float p, t; 00015 int ii=0; 00016 char pname[12],stval[6]; 00017 DIR *d = opendir("/local"); // Opens the root directory of the local file system 00018 struct dirent *pdir; 00019 int indice=1; 00020 while((pdir = readdir(d)) != NULL) { // Print the names of the files in the local file system 00021 pc.printf("%u %s\r",indice, pdir->d_name); 00022 if(strstr(pdir->d_name,"OUT")== pdir->d_name) { 00023 indice++; 00024 } 00025 } 00026 closedir(d); 00027 strcpy(pname,"/local/out"); 00028 sprintf(stval,"%02u",indice); 00029 strcat(pname,stval); 00030 strcat(pname,".txt"); 00031 00032 FILE *fp = fopen(pname, "w"); // Open "out.txt" on the local file system for writing 00033 myled4=0; 00034 while(1) { 00035 myled = 1; 00036 00037 bmp085.update(); 00038 p = bmp085.get_pressure(); 00039 t = bmp085.get_temperature(); 00040 // if(t>24.0){ 00041 // myled4=1; 00042 // }else{ 00043 // myled4=0; 00044 // } 00045 pc.printf("p:%6.2f hPa / t:%6.2f C\r", p, t); 00046 00047 if(ii<60){ 00048 ii=ii+1; 00049 fprintf(fp,"p:%6.2f hPa / t:%6.2f C\r", p, t); 00050 }else{ 00051 fclose(fp); 00052 myled4=1; 00053 } 00054 00055 myled = 0; 00056 wait(0.5); 00057 } 00058 }
Generated on Fri Jul 15 2022 05:02:23 by
1.7.2