Kyle Zampaglione
/
SlotSensorsTest
Code for Slot Sensor readout. Prints to text file on mbed.
Diff: main.cpp
- Revision:
- 3:a93f3494e6c1
- Parent:
- 2:c789547682d8
- Child:
- 4:9ea938dc72f8
diff -r c789547682d8 -r a93f3494e6c1 main.cpp --- a/main.cpp Tue Jul 02 22:44:08 2013 +0000 +++ b/main.cpp Wed Jul 03 16:48:21 2013 +0000 @@ -5,17 +5,20 @@ DigitalIn sensor1(p11); DigitalIn sensor2(p12); +LocalFileSystem local("local"); Timer t; -Timer timer1; int change = 0; +int count = 0; +const int endcount = 10; int main() { 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; @@ -29,6 +32,14 @@ t.stop(); pc.printf("End. Time taken was %f seconds \n \r", t.read()); change = 0; + fprintf(fp, "%f \n \r", t.read()); + count++; + } + if (count==endcount) { + pc.printf("Done"); + fclose(fp); + return 0; + }