code using the sonic sensor to activate motor when the distance value dips beneath 50cm, seems to be a problem compiling with the else if statement. Apparently an unclosed bracket.
Dependencies: SRF02 Servo mbed
Revision 3:732faa546abb, committed 2017-04-25
- Comitter:
- mspeed93
- Date:
- Tue Apr 25 12:18:31 2017 +0000
- Parent:
- 2:9179421b2288
- Commit message:
- another format update
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Apr 25 12:15:22 2017 +0000 +++ b/main.cpp Tue Apr 25 12:18:31 2017 +0000 @@ -168,17 +168,17 @@ while(1) { - int Ldistance = Lsensor.getDistanceCm(); //reads the distance value the ultrasonic sensors detect - int Rdistance = Rsensor.getDistanceCm(); // for front, left, and right sensors + int Ldistance = Lsensor.getDistanceCm(); /reads the distance value the ultrasonic sensors detect + int Rdistance = Rsensor.getDistanceCm(); // for front, left, and right sensors int Fdistance = Fsensor.getDistanceCm(); - if ((RFlame == 0) || (LFlame == 0)) { //conditional statement: if one or the other flame sensors detect + if ((RFlame == 0) || (LFlame == 0)) { //conditional statement: if one or the other flame sensors detect Extinguish(); - } //fire then the extinguish function is called + } //fire then the extinguish function is called - if (Fdistance > 22) { //using the distance value in front forward drive or turning functions - //are determined + if (Fdistance > 22) { //using the distance value in front forward drive or turning functions + //are determined Forward_Drive(); pos_val = pos_val + step_size; @@ -187,8 +187,8 @@ wait(0.5); } - else if (Fdistance <= 22) { //activates turning function if front distance drops - //beneath 22cm + else if (Fdistance <= 22) { //activates turning function if front distance drops + //beneath 22cm Turning(); pos_val = pos_val + step_size; if (pos_val > 1.0) pos_val = 0.0; @@ -196,8 +196,8 @@ wait(0.5); } - if ((Ldistance <= 20) && (Fdistance >= 22)) { //measures the distance to the side of the robot and the front - Turn_right(); //and turns away as appropriate using the slower turning functions + if ((Ldistance <= 20) && (Fdistance >= 22)) { //measures the distance to the side of the robot and the front + Turn_right(); //and turns away as appropriate using the slower turning functions pos_val = pos_val + step_size; if (pos_val > 1.0) pos_val = 0.0; @@ -205,8 +205,8 @@ wait(0.5); } - else if ((Rdistance <= 20) && (Fdistance >= 22)) { //measures the distance to the side of the robot and the front - Turn_left(); //and turns away as appropriate using the slower turning functions + else if ((Rdistance <= 20) && (Fdistance >= 22)) { //measures the distance to the side of the robot and the front + Turn_left(); //and turns away as appropriate using the slower turning functions if (pos_val > 1.0) pos_val = 0.0;