PIDs and fun
Dependencies: btbee m3pi_ng mbed FatFileSystemCpp
Diff: main.cpp
- Revision:
- 1:936e329e840a
- Parent:
- 0:4d1ae7eb0070
- Child:
- 2:1e947dcc40cb
diff -r 4d1ae7eb0070 -r 936e329e840a main.cpp --- a/main.cpp Fri May 22 13:34:01 2015 +0000 +++ b/main.cpp Fri May 22 14:06:50 2015 +0000 @@ -6,7 +6,7 @@ m3pi m3pi; btbee btbee; DigitalIn m3pi_pb(p21); -DigitalIn m3pi_IN[] = {(p12),(p21)}; +DigitalIn m3pi_IN[] = {(p12)}; DigitalOut mbed_led[] = {(LED1), (LED2),(LED3), (LED4)}; DigitalOut m3pi_led[] = {(p13), (p14), (p15), (p16), (p17), (p18), (p19), (p20)}; @@ -21,7 +21,9 @@ int main() { - + double IR; + +while(1) { btbee.reset(); m3pi_pb.mode(PullUp); @@ -37,7 +39,7 @@ btbee.printf("PC connected. Press the button \n"); } - + m3pi.cls(); Timer LapTimer; char Bat[] = {'V','o','l','t',' ','i','s'}; @@ -73,9 +75,10 @@ btbee.printf("Finished calibrating \n"); - if (m3pi_IN [0] == 0) { - btbee.printf("Obstacle detected. Stopping program"); - exit(1); + while (m3pi_IN [0] == 0) { + btbee.printf("Obstacle detected. Please remove to continue"); + m3pi.stop(); + wait(3.0); } float right; @@ -94,9 +97,11 @@ btbee.printf("Now starting \n"); - while (1) { + - + while (1) { + + // Get the position of the line. current_pos_of_line = m3pi.line_position(); proportional = current_pos_of_line; @@ -209,4 +214,6 @@ } -} \ No newline at end of file +} + +}