02/07/15
Dependencies: mbed
main.cpp@68:c6399471ea49, 2015-08-26 (annotated)
- Committer:
- aidanPJG
- Date:
- Wed Aug 26 16:08:09 2015 +0000
- Revision:
- 68:c6399471ea49
- Parent:
- 67:04d67617131a
- Child:
- 69:74bffa1d3f7f
working with multiple iteration on the same side. Keeps going without user interaction
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 | 17:d9fb4a3780c7 | 3 | #include "Distance.h" |
ADAMSTRUTT | 35:085a674c9fdf | 4 | #include "Data.h" |
aidanPJG | 48:e9578f56534a | 5 | #include "UserInput.h" |
aidanPJG | 56:bf08d9e50ccc | 6 | #include "AddDetails.h" |
ADAMSTRUTT | 35:085a674c9fdf | 7 | |
aidanPJG | 25:bab86a12e9ad | 8 | Serial pc(USBTX, USBRX); // tx, rx |
aidanPJG | 59:2cbbd6fea55b | 9 | DigitalOut led1(LED1); |
aidanPJG | 59:2cbbd6fea55b | 10 | DigitalOut led2(LED2); |
aidanPJG | 65:08b3eb9b95dd | 11 | string handshake(); |
aidanPJG | 59:2cbbd6fea55b | 12 | void run(); |
aidanPJG | 68:c6399471ea49 | 13 | int listen(); |
ADAMSTRUTT | 17:d9fb4a3780c7 | 14 | |
ADAMSTRUTT | 20:0b2279011691 | 15 | int main(void) |
aidanPJG | 7:d6f78ba7c5f7 | 16 | { |
aidanPJG | 68:c6399471ea49 | 17 | |
aidanPJG | 65:08b3eb9b95dd | 18 | if (handshake() == "success") |
aidanPJG | 65:08b3eb9b95dd | 19 | { |
aidanPJG | 65:08b3eb9b95dd | 20 | run(); |
aidanPJG | 65:08b3eb9b95dd | 21 | } |
aidanPJG | 65:08b3eb9b95dd | 22 | led2= 1; |
aidanPJG | 59:2cbbd6fea55b | 23 | } |
aidanPJG | 68:c6399471ea49 | 24 | |
aidanPJG | 65:08b3eb9b95dd | 25 | string handshake() |
aidanPJG | 59:2cbbd6fea55b | 26 | { |
aidanPJG | 59:2cbbd6fea55b | 27 | unsigned char input; |
aidanPJG | 59:2cbbd6fea55b | 28 | pc.printf("a\n"); |
aidanPJG | 59:2cbbd6fea55b | 29 | |
aidanPJG | 59:2cbbd6fea55b | 30 | while(true) |
aidanPJG | 59:2cbbd6fea55b | 31 | { |
aidanPJG | 59:2cbbd6fea55b | 32 | input = pc.getc(); |
aidanPJG | 59:2cbbd6fea55b | 33 | if (input == 'a') |
aidanPJG | 59:2cbbd6fea55b | 34 | { |
aidanPJG | 66:b642dac6f65d | 35 | led1 = 1; |
aidanPJG | 65:08b3eb9b95dd | 36 | return "success" ;// run(); |
aidanPJG | 59:2cbbd6fea55b | 37 | } |
aidanPJG | 59:2cbbd6fea55b | 38 | } |
aidanPJG | 59:2cbbd6fea55b | 39 | } |
aidanPJG | 59:2cbbd6fea55b | 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 | 59:2cbbd6fea55b | 44 | calculate(distance,pins); |
aidanPJG | 59:2cbbd6fea55b | 45 | } |