Line Robot - Basic lessons - Exercises - Zigzag
Task: drive Your robot along a zigzag path.
Program Your robot to go zigzag: for example 5 cm straight, then rotate 45° to the right, go 5 cm straight, 45° left, and so on.
Solution
void RobotLine::loop() {
go(50, 50);
delayMs(1000);
go(50, -50); // Start rotating right
delayMs(500);
go(50, 50);
delayMs(1000);
go(-50, 50); // Start rotating left
delayMs(500);
}