Kyle Zampaglione
/
SlotSensorsTest
Code for Slot Sensor readout. Prints to text file on mbed.
main.cpp@1:b057042a9427, 2013-07-02 (annotated)
- Committer:
- kzampag
- Date:
- Tue Jul 02 22:36:01 2013 +0000
- Revision:
- 1:b057042a9427
- Parent:
- 0:6aa040f8bf2c
Debounce
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kzampag | 0:6aa040f8bf2c | 1 | #include "mbed.h" |
kzampag | 1:b057042a9427 | 2 | #include "DebounceIn.h" |
kzampag | 0:6aa040f8bf2c | 3 | |
kzampag | 0:6aa040f8bf2c | 4 | Serial pc(USBTX, USBRX); // tx, rx |
kzampag | 0:6aa040f8bf2c | 5 | |
kzampag | 0:6aa040f8bf2c | 6 | |
kzampag | 1:b057042a9427 | 7 | DebounceIn sensor1(p11); |
kzampag | 1:b057042a9427 | 8 | DebounceIn sensor2(p12); |
kzampag | 0:6aa040f8bf2c | 9 | |
kzampag | 0:6aa040f8bf2c | 10 | Timer t; |
kzampag | 1:b057042a9427 | 11 | |
kzampag | 0:6aa040f8bf2c | 12 | |
kzampag | 0:6aa040f8bf2c | 13 | |
kzampag | 0:6aa040f8bf2c | 14 | int main() |
kzampag | 0:6aa040f8bf2c | 15 | { |
kzampag | 0:6aa040f8bf2c | 16 | pc.printf("Break sensor to start timer \n \r"); |
kzampag | 1:b057042a9427 | 17 | |
kzampag | 0:6aa040f8bf2c | 18 | while(1) { |
kzampag | 1:b057042a9427 | 19 | |
kzampag | 1:b057042a9427 | 20 | if (sensor1) { |
kzampag | 1:b057042a9427 | 21 | t.reset(); |
kzampag | 1:b057042a9427 | 22 | t.start(); |
kzampag | 1:b057042a9427 | 23 | pc.printf("Start \n \r"); |
kzampag | 1:b057042a9427 | 24 | |
kzampag | 1:b057042a9427 | 25 | |
kzampag | 0:6aa040f8bf2c | 26 | } // end sensor 1 |
kzampag | 1:b057042a9427 | 27 | |
kzampag | 0:6aa040f8bf2c | 28 | |
kzampag | 0:6aa040f8bf2c | 29 | if (sensor2) { |
kzampag | 1:b057042a9427 | 30 | t.stop(); |
kzampag | 1:b057042a9427 | 31 | pc.printf("End. Time taken was %f seconds \n \r", t.read()); |
kzampag | 1:b057042a9427 | 32 | |
kzampag | 0:6aa040f8bf2c | 33 | |
kzampag | 0:6aa040f8bf2c | 34 | } // end sensor2 |
kzampag | 0:6aa040f8bf2c | 35 | |
kzampag | 0:6aa040f8bf2c | 36 | } |
kzampag | 0:6aa040f8bf2c | 37 | } |