02/07/15

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Calculate.cpp

Committer:
aidanPJG
Date:
2015-07-08
Revision:
30:ab3a436e8968
Parent:
26:4289549b2d21
Child:
31:bea1117f14fb

File content as of revision 30:ab3a436e8968:

#include "mbed.h"
#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.   
//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 calculate()
{
    pc.printf("new program \n");                                            //alert user of initialisation   
      
    int i = 0; 
    while( i < 6)
    {
        while(!sensor[i]) 
        {
            if(sensor[i + 1]) {
                sensor_time = time(NULL); 
                i++; 
                }                                                         //error checking incase next one is done
        }
        sensor_time = time(NULL); 
        pc.printf(" %dth sensor  %d : \t", i,sensor_time);  
        i++;
    } 
      pc.printf("Calculate completed"); 
       
      
}