adding a random turn to BumperBot

In this section, you’ll make a small change to the BumperBot program to make it a little more interesting. Recall that when the TriBot bumps into something, it backs up and turns in a different direction. The distance the robot turns doesn’t need to be any particular value; you simply want to have the robot point in a different direction. You can use a Random block to control the distance the robot turns, which will make the program less predictable.

Figure 14-15 shows the part of the BumperBot program that you need to change. This is the code that runs after the Touch Sensor determines that the TriBot has run into something. The first five blocks make the robot back up, and the final Move block turns the robot. ...

Get The Art of LEGO MINDSTORMS NXT-G Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.