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@71:60f06e7e50a3, 2015-09-03 (annotated)
- Committer:
- aidanPJG
- Date:
- Thu Sep 03 15:32:01 2015 +0000
- Revision:
- 71:60f06e7e50a3
- Parent:
- 70:168d67695a65
tried to add date but it failed;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ADAMSTRUTT | 17:d9fb4a3780c7 | 1 | #include "mbed.h" |
ADAMSTRUTT | 17:d9fb4a3780c7 | 2 | #include "Calculate.h" |
ADAMSTRUTT | 35:085a674c9fdf | 3 | #include "Data.h" |
aidanPJG | 48:e9578f56534a | 4 | #include "UserInput.h" |
aidanPJG | 56:bf08d9e50ccc | 5 | #include "AddDetails.h" |
ADAMSTRUTT | 35:085a674c9fdf | 6 | |
aidanPJG | 70:168d67695a65 | 7 | Serial pc(USBTX, USBRX); // tx, rx comms for the pc to talk to the mbed |
aidanPJG | 70:168d67695a65 | 8 | DigitalOut led1(LED1); //led on the mbed, used for debugging |
aidanPJG | 70:168d67695a65 | 9 | DigitalOut led2(LED2); //" |
aidanPJG | 70:168d67695a65 | 10 | |
aidanPJG | 65:08b3eb9b95dd | 11 | string handshake(); |
aidanPJG | 59:2cbbd6fea55b | 12 | void run(); |
aidanPJG | 68:c6399471ea49 | 13 | int listen(); |
ADAMSTRUTT | 17:d9fb4a3780c7 | 14 | |
aidanPJG | 70:168d67695a65 | 15 | int main(void) //the first method that is run |
aidanPJG | 7:d6f78ba7c5f7 | 16 | { |
aidanPJG | 68:c6399471ea49 | 17 | |
aidanPJG | 70:168d67695a65 | 18 | if (handshake() == "success") //if the handshake returns success message |
aidanPJG | 65:08b3eb9b95dd | 19 | { |
aidanPJG | 70:168d67695a65 | 20 | run(); //then we run the program |
aidanPJG | 65:08b3eb9b95dd | 21 | } |
aidanPJG | 65:08b3eb9b95dd | 22 | led2= 1; |
aidanPJG | 59:2cbbd6fea55b | 23 | } |
aidanPJG | 68:c6399471ea49 | 24 | |
aidanPJG | 70:168d67695a65 | 25 | string handshake() //to test that the pc and mbed have comms |
aidanPJG | 70:168d67695a65 | 26 | { |
aidanPJG | 70:168d67695a65 | 27 | unsigned char input; //what the pc sends |
aidanPJG | 70:168d67695a65 | 28 | pc.printf("a\n"); //send the pc an 'a' |
aidanPJG | 59:2cbbd6fea55b | 29 | |
aidanPJG | 70:168d67695a65 | 30 | while(true) //keep doing this |
aidanPJG | 59:2cbbd6fea55b | 31 | { |
aidanPJG | 70:168d67695a65 | 32 | input = pc.getc(); //what the pc sends |
aidanPJG | 70:168d67695a65 | 33 | if (input == 'a') //did the pc send an 'a' as well? |
aidanPJG | 59:2cbbd6fea55b | 34 | { |
aidanPJG | 70:168d67695a65 | 35 | led1 = 1; //turn led on |
aidanPJG | 70:168d67695a65 | 36 | return "success" ; //return "success" |
aidanPJG | 59:2cbbd6fea55b | 37 | } |
aidanPJG | 59:2cbbd6fea55b | 38 | } |
aidanPJG | 59:2cbbd6fea55b | 39 | } |
aidanPJG | 70:168d67695a65 | 40 | void run() |
aidanPJG | 59:2cbbd6fea55b | 41 | { |
aidanPJG | 55:58e9836f5ad1 | 42 | int pins = inputNoOfPins(); //gets number of pins |
aidanPJG | 55:58e9836f5ad1 | 43 | double distance = inputDistance(); //gets the distance between the pins |
aidanPJG | 71:60f06e7e50a3 | 44 | string date = inputDate(); |
aidanPJG | 71:60f06e7e50a3 | 45 | calculate(distance,pins,date); //runs calculate method. |
aidanPJG | 59:2cbbd6fea55b | 46 | } |