der Roboter
/
TurnAround
Insert this into Randi's program!
Diff: main.cpp
- Revision:
- 0:5318196e952d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed May 21 12:26:34 2014 +0000 @@ -0,0 +1,46 @@ + #include "mbed.h" + #include "m3pi_ng.h" + + DigitalOut myled(LED1); + void turn_around (int array[5]); + m3pi George; + + int main() + { + + } + + void turn_around (int array[5]) + { + // Declaring Variables + int threshold = 200; + int speed = 0.3; + + bool turn = true; + //NOT NEEDED : int amt = 0; + // Check to see if all sensors are lower than threshold + + for(int i = 0; i < 5; i++) + { + if(array[i] > threshold) + { + turn = false; + } + + } + + while (turn) + { + George.left_motor(speed); + George.right_motor(-speed); + + for(int i = 0; i < 5; i++) + { + if(array[i] > threshold) + { + turn = true; + } + } + + } + } \ No newline at end of file