![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
testing forking
Fork of ConsolTest by
Diff: main.cpp
- Revision:
- 7:d6f78ba7c5f7
- Parent:
- 4:e61cd14ec4f0
- Child:
- 8:b8a798d32630
--- a/main.cpp Thu Jul 02 14:40:20 2015 +0000 +++ b/main.cpp Fri Jul 03 13:36:06 2015 +0000 @@ -4,30 +4,47 @@ #include <iostream> Serial pc(USBTX, USBRX); // tx, rx //defines the communication between MBed and pc -DigitalIn input(p8); //input from diode. Digital 1 is beam unbroken? -DigitalOut led(LED1); //testing purposes - +DigitalIn sensor1(p8); //input from diode. Digital 1 is beam unbroken? +DigitalIn sensor2(p9); +DigitalIn sensor3(p10); +DigitalIn sensor4(p11); +DigitalOut led(LED1); + //testing purposes +int main() +{ -int main() { - int line = 0; //line counter - pc.printf("new program \n"); //lert user of initialisation + pc.printf("new program \n"); //alert user of initialisation - while(1) { //loops continuously - if (input) //checks the digital input from the diode. + time_t sensor1_time ; + time_t sensor2_time ; + time_t sensor3_time ; + double sensor2Seconds; + double sensor3Seconds; + + // while(!sensor4) //until last sensor because that will be when its over. + // { + if (sensor1) //checks the digital input from the diode. { - pc.printf("Message %d : \t", line); - pc.printf("DigitalIn: 1 \n"); + led = 1; - line = line + 1; - + sensor1_time = time(NULL); + } + if (sensor2) //checks the digital input from the diode. + { + + led = 1; + sensor2_time = time(NULL); + sensor2Seconds = difftime(sensor2_time, sensor1_time); + pc.printf(" 2nd time %d : \t", sensor2Seconds); } - else - { - pc.printf("Message %d : \t", line); - pc.printf("DigitalIn 0\n"); - led = 0; - line = line + 1 ; - + if (sensor3) //checks the digital input from the diode. + { + + led = 1; + sensor3_time = time(NULL); + sensor3Seconds = difftime(sensor3_time, sensor2_time); + pc.printf("3rd time %d : \t", sensor3Seconds ); } - } -} \ No newline at end of file + + // } +}