Soccer Robot C - Basic lessons - Exercises - Zigzag
Task: drive Your robot along a zigzag path.
Program Your robot to go zigzag: for example approx. 5 cm straight, then rotate approx. 45° to the right, go 5 cm straight, 45° left, and so on. It doesn't matter if it goes 4 or 15 cm, only the logic matters.
Solution
void RobotSoccer::loop() {
go(50, 0);
delayMs(1000);
go(0, 0, 20); // Start rotating right
delayMs(500);
go(50, 0);
delayMs(1000);
go(0, 0, -20); // Start rotating left
delayMs(500);
}