Robot code for searching an object and charging at it.
Dependencies: HCSR04 Motor mbed
Diff: main.cpp
- Revision:
- 37:a08d2e37b7e6
- Parent:
- 35:89e13f72cd84
--- a/main.cpp Tue Jun 09 10:28:16 2015 +0000 +++ b/main.cpp Wed Oct 12 11:13:45 2016 +0000 @@ -13,11 +13,25 @@ // by detetecting an object and charging towards it. // It uses the following basic functions: // -// move_forward(speed) -// - Used to move the robot toward a detected object. -// The robot will move forwards in a straight line -// until it detects the arena line where -// it will use reverse() to move back +// forwards(speed) +// - Sets the motor speeds in order to go forwards. +// +// reverse(speed) +// - Sets the motor speeds in order to go backwards. +// +// turn_left(speed) +// - Sets the motor speeds to turn the robot to the left. +// +// turn_right(speed) +// - Sets the motor speeds to turn the robot to the right. +// +// stop() +// - Sets the motor speeds to 0. +// +// turn_led_on(LED) +// - Turns on the LED on the mbed specified by the +// number passed as the argument +// Values need to be between 1 and 4 // // detect_object(range, speed) // - Used to detect an object, the robot will @@ -31,12 +45,6 @@ // 1 - if line detected from the front // -1 - if line detected from the back // -// reverse(speed) -// - Reverses the robot in a straight line at given speed. -// -// stop() -// - Stops the robot. -// // move_random(speed) // - Used to move the robot randomly: the robot will either // move forward, move backward, or turn around. The movement @@ -104,7 +112,7 @@ if (detect_o == 1) { - move_forward(forwardspeed); + forwards(forwardspeed); while (true) {