Mission Instructions

4. Pre-Code: Turn the Other Way

In a similar manner, can your robot manage to turn the other way? Let’s say if there’s a wall in front of the robot and a wall to the side with the sensor, it would be a good idea for the robot to attempt a turn in the other direction - as we are not dealing with dead-ends for the moment.

Try this code that will turn right if there’s a wall in front and a wall to the left


What happened?

Chances are your robot hit the wall with its back section.  Oops. It seems it’s following the wall too closely. The GoPiGo needs space to turn !  Adjust your code and place your robot accordingly.

When you will build your canyon system, you will need to take those measurements into consideration.  How wide should the corridor be?  How far from the wall should the robot be? 


Make It a Function

Now save your thinking as a second custom function. Make sure to name this one very carefully, too!  If your last function was named “Turn Left”, this one should probably be named, “Turn Right”.