Kyle Zampaglione
/
SlotSensorsTest
Code for Slot Sensor readout. Prints to text file on mbed.
Diff: main.cpp
- Revision:
- 2:c789547682d8
- Parent:
- 0:6aa040f8bf2c
- Child:
- 3:a93f3494e6c1
--- a/main.cpp Tue Jul 02 22:31:03 2013 +0000 +++ b/main.cpp Tue Jul 02 22:44:08 2013 +0000 @@ -8,35 +8,29 @@ Timer t; Timer timer1; -Timer timer2; +int change = 0; int main() { pc.printf("Break sensor to start timer \n \r"); - + while(1) { - if (sensor1) { - timer1.start(); - if (timer1.read_ms()>500) { - t.reset(); - t.start(); - pc.printf("Start \n \r"); - timer1.reset(); - } - - } // end sensor 1 - + + if (change == 0 && sensor1) { + change = 1; + t.reset(); + t.start(); + pc.printf("Start \n \r"); + } - if (sensor2) { - timer1.reset(); - timer1.start(); - if (timer1.read_ms()>500) { - t.stop(); - pc.printf("End. Time taken was %f seconds \n \r", t.read()); - } - } // end sensor2 + if (change && sensor2) { + t.stop(); + pc.printf("End. Time taken was %f seconds \n \r", t.read()); + change = 0; + } + } }