02/07/15

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Revision:
38:da262dc4f90a
Parent:
33:929f1755664b
Child:
39:3527578e78dd
--- a/Calculate.cpp	Wed Jul 08 08:42:29 2015 +0000
+++ b/Calculate.cpp	Wed Jul 08 10:11:44 2015 +0000
@@ -4,6 +4,8 @@
 #include <iostream>
 //#include "Distance.h"
 
+void printArray(int array[6]);
+
  //mbed pins
 extern Serial pc;                                                                   //defines the communication between MBed and pc
 int NoOfPins = 6;                                                                         //for how many sensors there are       
@@ -19,7 +21,7 @@
 int calculate(float distance)
 {
     pc.printf("new program \n");                                            //alert user of initialisation   
-      
+     
     int i = 0; 
     while( i < 6)
     {
@@ -43,11 +45,15 @@
         i++;
     } 
       pc.printf(" \n Calculate completed \n");                                      //alert to let user know it completed
-      for (int i = 0; i < 5 ; i++)                                          //printing module for array
-      {
-        pc.printf(" times: %d  \t", times[i]); 
-       }
-      
+      printArray(times);
+  
 }
 
-
+void printArray(int array[6])
+      {
+        for (int i = 0; i < 5 ; i++)                                     //printing module for array                              
+        {
+             pc.printf(" times: %d  \t", times[i]); 
+         }
+         
+      }