![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
02/07/15
Dependencies: mbed
Diff: Calculate.cpp
- Revision:
- 53:10f4f519ba69
- Parent:
- 52:d21fc7266b66
- Child:
- 56:bf08d9e50ccc
--- a/Calculate.cpp Thu Jul 16 14:01:24 2015 +0000 +++ b/Calculate.cpp Thu Jul 16 14:08:26 2015 +0000 @@ -4,12 +4,12 @@ #include <iostream> #include "Distance.h" -void printArray(double array[20], int timesArray[20]); +void printArray(double array[20], int timesArray[20], int NoOfPins); void data(int sensor_number, int time, double speed); //mbed pins extern Serial pc; //defines the communication between MBed and pc -int NoOfPins = 3; //for how many sensors there are +//int NoOfPins = 3; //for how many sensors there are DigitalIn sensor[20] = {p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24} ; //array of sensors. @@ -22,8 +22,9 @@ -int calculate(double distance) +int calculate(double distance, int NoOfPins) { + pc.printf("new program \n"); //alert user of initialisation int i = 0; @@ -49,11 +50,11 @@ i++; } pc.printf(" \n Calculate completed \n"); //alert to let user know it completed - printArray(speeds, times); + printArray(speeds, times, NoOfPins); } -void printArray(double array[20], int timesArray[20]) +void printArray(double array[20], int timesArray[20], int NoOfPins) { for (int i = 0; i < NoOfPins ; i++) //printing module for array {