02/07/15

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Revision:
31:bea1117f14fb
Parent:
30:ab3a436e8968
Child:
32:792c4239a738
diff -r ab3a436e8968 -r bea1117f14fb Calculate.cpp
--- a/Calculate.cpp	Wed Jul 08 07:47:28 2015 +0000
+++ b/Calculate.cpp	Wed Jul 08 07:55:13 2015 +0000
@@ -2,14 +2,17 @@
 #include <time.h>
 #include <string>
 #include <iostream>
+
  //mbed pins
 extern Serial pc;                                                                   //defines the communication between MBed and pc
 int NoOfPins = 6;                                                                         //for how many sensors there are       
-DigitalIn sensor[6] = {p5,p6,p7,p8,p9,p10} ;                                                 //array of sensors.   
+DigitalIn sensor[6] = {p5,p6,p7,p8,p9,p10} ;                                                 //array of sensors.  
+
+ 
 //c++ variables
     time_t sensor_time ;                            //time at which sensor is broken
     double timeDifference;                          //time between 2 sensors - not used right now
-    double times[6];                                //array the size of #pins
+    int times[6];                                //array the size of #pins
                                                   
 int calculate()
 {
@@ -27,10 +30,14 @@
         }
         sensor_time = time(NULL); 
         pc.printf(" %dth sensor  %d : \t", i,sensor_time);  
+        times[i] = sensor_time;                                                 //adds sensor times to array for logging.
         i++;
     } 
-      pc.printf("Calculate completed"); 
-       
+      pc.printf("Calculate completed");                                      //alert to let user know it completed
+      for (int i = 6 - 1; i >= 0; i--)                                          //printing module for array
+      {
+        pc.printf(" times  %d : \t", times[i]); 
+       }
       
 }