Craig Evans
/
3pi_Move
Example to move the robot.
Fork of 3pi_Line_Follow by
code.cpp
- Committer:
- eencae
- Date:
- 2018-03-20
- Revision:
- 0:008c53db1931
- Child:
- 1:d8c15d5b8eac
File content as of revision 0:008c53db1931:
#include "main.h" void repeat() { float speed = 0.5; robot.scan(); // in range -1 to 1, no error when line is at 0.0 // number is negative when the line is to the left // number is positive when the line is to the right float position = robot.read_line(); robot.display_data(); float step = 0.4*position; // + when line to right // - for line to left if (position < 0.0) { // line to the left...need to turn left robot.left_motor(speed+step); robot.right_motor(speed); } else { // line to the right...need to turn right robot.left_motor(speed); robot.right_motor(speed-step); } }