02/07/15

Dependencies:   mbed

Dependents:   TabbedGUIMbed

Calculate.cpp

Committer:
aidanPJG
Date:
2015-07-07
Revision:
25:bab86a12e9ad
Parent:
24:92600b1d15b1
Child:
26:4289549b2d21

File content as of revision 25:bab86a12e9ad:

#include "mbed.h"
#include <time.h>
#include <string>
#include <iostream>
 //mbed pins
extern Serial pc;
                                         //defines the communication between MBed and pc
DigitalIn sensor[3] = {p8,p9,p10};                                                       //input from diode. Digital 1 is beam unbroken?
 

DigitalOut led(LED1);    
//c++ variables
    time_t sensor_time ;
    double sensor2Seconds; 
    double sensor3Seconds;
                                                   //testing purposes 
int calculate()
{
    pc.printf("new program \n");                                            //alert user of initialisation   
      
    int i = 0; 
    while( i < 3)
    {
        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"); 
       
      
}