Rosie Lewis
/
mbed_menu
menu for accelerometer
menu_menu.cpp
- Committer:
- mzpf46
- Date:
- 2017-11-07
- Revision:
- 0:8d536d5c58c6
- Child:
- 1:4938aa677cb3
File content as of revision 0:8d536d5c58c6:
#include "mbed.h" #include "stdio.h" #include "math.h" #include "ADXL362.h" #define HIGH 1 #define LOW 0 DigitalOut myled1(LED1); /* LED1 */ Serial pc(USBTX, USBRX); ADXL362 adxl362(p11, p12, p13, p10); LocalFileSystem local("local"); int matlabdata; char usercmd; char N[1000]; //Number of samples char T [1000]; //Sample period int main() { FILE *samplesettings; //Create file with pointer char res[100]; matlabdata=pc.scanf("%s",res); while(1) if(!strcmp(res,"1")) { myled1 = HIGH; char N[1000]; pc.scanf("%s",&N); samplesettings = fopen("/local/samplesettings.txt", "w");//Open file for writing fprintf(samplesettings,"%s",N); //Writes settings values onto file fclose(samplesettings); break; } else if(!strcmp(res,"2")) { //Define variables for output char value1[100]; samplesettings = fopen("/local/samplesettings.txt" , "r"); //Open file for reading fscanf(samplesettings,"%[^\n]", value1); pc.printf("%s", value1); fclose(samplesettings); //Close file } else pc.printf ("Error\n"); }