02/07/15

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Revision:
47:1dc3b5f7bf4a
Parent:
44:3b45ec49bc44
Child:
50:d794595c6868
diff -r 70031ad8f2b9 -r 1dc3b5f7bf4a Calculate.cpp
--- a/Calculate.cpp	Thu Jul 09 13:37:43 2015 +0000
+++ b/Calculate.cpp	Mon Jul 13 10:34:29 2015 +0000
@@ -4,27 +4,27 @@
 #include <iostream>
 #include "Distance.h"
 
-void printArray(int array[6]);
+void printArray(int array[3]);
 void data(int sensor_number, int speed);
 
  //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.  
+int NoOfPins = 3;                                                                         //for how many sensors there are       
+DigitalIn sensor[3] = {p5,p6,p7} ;                                                 //array of sensors.  
 
  
 //c++ variables
     time_t sensor_time ;                            //time at which sensor is broken
     int timeDiff;                          //time between 2 sensors - not used right now   
     float speed;
-    int times[6];                                //array the size of #pins
+    int times[3];                                //array the size of #pins
     double speeds[6];                                //array of speeds            
 int calculate(float distance)
 {
     pc.printf("new program \n");                                            //alert user of initialisation   
      
     int i = 0; 
-    while( i < 6)
+    while( i < 3)
     {
         while(!sensor[i]) 
         {
@@ -51,13 +51,13 @@
   
 }
 
-void printArray(int array[6])
+void printArray(int array[3])
       {
-        for (int i = 0; i < 5 ; i++)                                     //printing module for array                              
+        for (int i = 0; i < 3 ; i++)                                     //printing module for array                              
         {
              pc.printf(" %d : %d  \t", i,times[i]); 
          }
-         for (int i = 0; i < 5 ; i++)                                     //printing to Datalog                            
+         for (int i = 0; i < 3 ; i++)                                     //printing to Datalog                            
         {
              data( i,times[i]); 
          }