On Github tybenz / presentation-hour-of-code
delay = 0.5; void loop() { moveForward(); turnLeft(); }
delay = 0; void loop() { turnRight(); }
delay = 0.1; void loop() { moveForward(); turnLeft(); }
delay = 0.5; moveForward(); moveForward(); moveForward(); turnRight(); moveForward(); moveForward(); turnRight(); moveForward(); turnRight(); moveForward(); turnLeft(); moveForward(); moveForward();
long toTheLeft, toTheRight; long inFront = ping(FRONT); if (inFront > 12) { car->moveForward(); } else { stop(); delay(1); toTheRight = ping(RIGHT); delay(1); toTheLeft = ping(LEFT); if (toTheLeft > 12) { turnLeft(); } else if (toTheRight > 12) { turnRight(); } else { // turnaround turnLeft(); turnLeft(); } }