![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
02/07/15
Dependencies: mbed
main.cpp
- Committer:
- aidanPJG
- Date:
- 2015-09-03
- Revision:
- 70:168d67695a65
- Parent:
- 69:74bffa1d3f7f
- Child:
- 71:60f06e7e50a3
File content as of revision 70:168d67695a65:
#include "mbed.h" #include "Calculate.h" #include "Data.h" #include "UserInput.h" #include "AddDetails.h" Serial pc(USBTX, USBRX); // tx, rx comms for the pc to talk to the mbed DigitalOut led1(LED1); //led on the mbed, used for debugging DigitalOut led2(LED2); //" string handshake(); void run(); int listen(); int main(void) //the first method that is run { if (handshake() == "success") //if the handshake returns success message { run(); //then we run the program } led2= 1; } string handshake() //to test that the pc and mbed have comms { unsigned char input; //what the pc sends pc.printf("a\n"); //send the pc an 'a' while(true) //keep doing this { input = pc.getc(); //what the pc sends if (input == 'a') //did the pc send an 'a' as well? { led1 = 1; //turn led on return "success" ; //return "success" } } } void run() { int pins = inputNoOfPins(); //gets number of pins double distance = inputDistance(); //gets the distance between the pins calculate(distance,pins); //runs calculate method. }