Kyle Zampaglione
/
SlotSensorsTest
Code for Slot Sensor readout. Prints to text file on mbed.
main.cpp
- Committer:
- kzampag
- Date:
- 2013-07-04
- Revision:
- 4:9ea938dc72f8
- Parent:
- 3:a93f3494e6c1
- Child:
- 5:7e1dcb3904dd
File content as of revision 4:9ea938dc72f8:
#include "mbed.h" Serial pc(USBTX, USBRX); // tx, rx DigitalIn sensor1(p5); DigitalIn sensor2(p6); LocalFileSystem local("local"); Timer t; 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) { if (change == 0 && sensor1) { change = 1; t.reset(); t.start(); pc.printf("Start \n \r"); } if (change && sensor2) { t.stop(); pc.printf("End. Time taken was %f seconds \n \r", t.read()); change = 0; fprintf(fp, "%f \n", t.read()); count++; } if (count==endcount) { pc.printf("Done"); fclose(fp); return 0; } } }