Kyle Zampaglione
/
SlotSensorsTest
Code for Slot Sensor readout. Prints to text file on mbed.
Diff: main.cpp
- Revision:
- 5:7e1dcb3904dd
- Parent:
- 4:9ea938dc72f8
- Child:
- 6:360247c0c7df
--- a/main.cpp Thu Jul 04 00:35:19 2013 +0000 +++ b/main.cpp Mon Jul 08 16:43:29 2013 +0000 @@ -9,7 +9,7 @@ Timer t; int change = 0; -int count = 0; +int count = 1; const int endcount = 10; @@ -17,14 +17,14 @@ { pc.printf("Break sensor to start timer \n \r"); FILE *fp = fopen("/local/test.txt", "w"); - while(1) { + while(1) { if (change == 0 && sensor1) { change = 1; t.reset(); t.start(); - pc.printf("Start \n \r"); + pc.printf("Start: Count= %d \n \r", count); } @@ -35,13 +35,22 @@ fprintf(fp, "%f \n", t.read()); count++; } - if (count==endcount) { + + if (count>endcount) { pc.printf("Done"); fclose(fp); return 0; + } + if (pc.readable()) { + char c = pc.getc(); + if(c == 'e') { + pc.printf("Program terminated"); + return 0; + } } + } }