PIDs and fun
Dependencies: btbee m3pi_ng mbed FatFileSystemCpp
Diff: main.cpp
- Revision:
- 3:ebe015c72bba
- Parent:
- 2:1e947dcc40cb
- Child:
- 4:0bcd7a924140
diff -r 1e947dcc40cb -r ebe015c72bba main.cpp --- a/main.cpp Wed May 27 11:38:48 2015 +0000 +++ b/main.cpp Wed May 27 11:49:58 2015 +0000 @@ -87,6 +87,7 @@ int counter = -1; int checkvar = 0; double Time1, Time2, Time3, Time4, Time5, TimeAve; + bool IR = 1; btbee.printf("\n"); btbee.printf("Now starting \n"); @@ -95,13 +96,16 @@ while (1) { - if(m3pi_IN [0] == 0) { - while (m3pi_IN [0] == 0) { + IR = m3pi_IN [0]; + + if(m3pi_IN [0] == 0 and IR == 0) { + while (m3pi_IN [0] == 0 and IR == 0) { btbee.printf("Obstacle detected. Please remove to continue"); m3pi.stop(); wait(3.0); } } + IR = 1; // Get the position of the line. current_pos_of_line = m3pi.line_position();