Craig Evans
/
3pi_Move
Example to move the robot.
Fork of 3pi_Line_Follow by
Diff: code.cpp
- Revision:
- 1:d8c15d5b8eac
- Parent:
- 0:008c53db1931
- Child:
- 2:ec75506e96a3
diff -r 008c53db1931 -r d8c15d5b8eac code.cpp --- a/code.cpp Tue Mar 20 16:28:07 2018 +0000 +++ b/code.cpp Tue Mar 20 16:37:12 2018 +0000 @@ -1,32 +1,9 @@ #include "main.h" +// code in here runs again and again 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); - } + // put your code in between the { and } brackets + } \ No newline at end of file