Rosie Lewis
/
mbed_menu
menu for accelerometer
Diff: menu_menu.cpp
- Revision:
- 0:8d536d5c58c6
- Child:
- 1:4938aa677cb3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/menu_menu.cpp Tue Nov 07 21:49:14 2017 +0000 @@ -0,0 +1,54 @@ +#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"); + +} \ No newline at end of file