Soccer Robot C - Basic lessons - Exercises - Boundary
Task: do not allow Your robot to cross a boundary.
Using a white stripe, make a square, or some other type of boundary on the dark surface, and program the robot so that it always moves inside the set limits (stripe).
Solution
void RobotSoccer::loop() {
if (setup())
go(50, 0);
if (line(4, 0)){
go(0, 0, 20);
delayMs(500);
go(50, 0);
}
}
Adjust the speeds and number of milliseconds. In the program, when transistor 4 of the front reflectance sensor detects black, the robot will rotate 180° in place and continue in the opposite direction, avoiding the boundary.