ultrasonic distance sensor
Dependencies: N5110 PowerControl SRF02 beep mbed
Fork of Ultrasonic by
datafile.h@3:bbfabbbc4291, 2015-05-11 (annotated)
- Committer:
- probrania7
- Date:
- Mon May 11 18:47:19 2015 +0000
- Revision:
- 3:bbfabbbc4291
- Parent:
- 2:184524f95eb1
Ultrasonic ver1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
probrania7 | 3:bbfabbbc4291 | 1 | /** |
probrania7 | 3:bbfabbbc4291 | 2 | @file datafile.h |
probrania7 | 3:bbfabbbc4291 | 3 | @function for writing files |
probrania7 | 3:bbfabbbc4291 | 4 | */ |
probrania7 | 2:184524f95eb1 | 5 | |
probrania7 | 2:184524f95eb1 | 6 | LocalFileSystem local("local"); //create local file system |
probrania7 | 3:bbfabbbc4291 | 7 | void writeDataToFile(char* data1); |
probrania7 | 2:184524f95eb1 | 8 | |
probrania7 | 3:bbfabbbc4291 | 9 | void writeDataToFile(char* data1) |
probrania7 | 2:184524f95eb1 | 10 | { |
probrania7 | 2:184524f95eb1 | 11 | //leds = 15; //turn on leds for feedback |
probrania7 | 2:184524f95eb1 | 12 | FILE *fp = fopen("/local/log.csv", "a"); //open 'log.csv' for apending |
probrania7 | 2:184524f95eb1 | 13 | |
probrania7 | 2:184524f95eb1 | 14 | //if the file doesnt exist it is created, if it exists, data is apended to the end |
probrania7 | 3:bbfabbbc4291 | 15 | fprintf(fp, "%0.2f cm\n",data1); //print string to file |
probrania7 | 3:bbfabbbc4291 | 16 | //fprintf(fp, "%0.2f C\n",data2); //print string to file |
probrania7 | 3:bbfabbbc4291 | 17 | //fprintf(fp, "%0.2f C\n",data3); //print string to file |
probrania7 | 2:184524f95eb1 | 18 | |
probrania7 | 2:184524f95eb1 | 19 | fclose(fp); //close file |
probrania7 | 2:184524f95eb1 | 20 | |
probrania7 | 2:184524f95eb1 | 21 | //leds = 0; //turn off leds to signify file access has finished |
probrania7 | 3:bbfabbbc4291 | 22 | } |
probrania7 | 3:bbfabbbc4291 | 23 |