Kyle Zampaglione
/
SlotSensorsTest
Code for Slot Sensor readout. Prints to text file on mbed.
main.cpp
- Committer:
- kzampag
- Date:
- 2013-07-02
- Revision:
- 0:6aa040f8bf2c
- Child:
- 1:b057042a9427
- Child:
- 2:c789547682d8
File content as of revision 0:6aa040f8bf2c:
#include "mbed.h" Serial pc(USBTX, USBRX); // tx, rx DigitalIn sensor1(p11); DigitalIn sensor2(p12); Timer t; Timer timer1; Timer timer2; 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 (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 } }