Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 #include "Calculate.h" 00003 #include "Data.h" 00004 #include "UserInput.h" 00005 #include "AddDetails.h" 00006 00007 Serial pc(USBTX, USBRX); // tx, rx comms for the pc to talk to the mbed 00008 DigitalOut led1(LED1); //led on the mbed, used for debugging 00009 DigitalOut led2(LED2); //" 00010 00011 string handshake(); 00012 void run(); 00013 int listen(); 00014 00015 int main(void) //the first method that is run 00016 { 00017 00018 if (handshake() == "success") //if the handshake returns success message 00019 { 00020 run(); //then we run the program 00021 } 00022 led2= 1; 00023 } 00024 00025 string handshake() //to test that the pc and mbed have comms 00026 { 00027 unsigned char input; //what the pc sends 00028 pc.printf("a\n"); //send the pc an 'a' 00029 00030 while(true) //keep doing this 00031 { 00032 input = pc.getc(); //what the pc sends 00033 if (input == 'a') //did the pc send an 'a' as well? 00034 { 00035 led1 = 1; //turn led on 00036 return "success" ; //return "success" 00037 } 00038 } 00039 } 00040 void run() 00041 { 00042 int pins = inputNoOfPins(); //gets number of pins 00043 double distance = inputDistance(); //gets the distance between the pins 00044 string date = inputDate(); 00045 calculate(distance,pins,date); //runs calculate method. 00046 }
Generated on Fri Jul 15 2022 03:23:27 by
1.7.2