02/07/15

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Revision:
22:34bc2f2f5b09
Parent:
20:0b2279011691
Child:
24:92600b1d15b1
--- a/Calculate.cpp	Tue Jul 07 12:37:34 2015 +0000
+++ b/Calculate.cpp	Tue Jul 07 12:46:56 2015 +0000
@@ -1,50 +1,50 @@
-//#include "mbed.h"
-//#include <time.h>
-//#include <string>
-//#include <iostream>
-// 
-//Serial pc(USBTX, USBRX); // tx, rx                                          //defines the communication between MBed and pc
-//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 calculate()
-//{
-//
-//    pc.printf("new program \n");                                            //alert user of initialisation   
-//      
-//    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.
-//        {
-//         
-//            led = 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);
-//        }
-//        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 );
-//        }
-//       
-//  //     }
-//}
+#include "mbed.h"
+#include <time.h>
+#include <string>
+#include <iostream>
+ 
+Serial pc(USBTX, USBRX); // tx, rx                                          //defines the communication between MBed and pc
+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 calculate()
+{
+
+    pc.printf("new program \n");                                            //alert user of initialisation   
+      
+    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.
+        {
+         
+            led = 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);
+        }
+        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 );
+        }
+       
+  //     }
+}