following a straight wall

The first section of NXT-G code will make the TriBot travel along the wall. You’ll use a Switch block to choose between two Move blocks, one that turns toward the wall and one that turns away from the wall. As the TriBot moves forward, this should keep it about the same distance from the wall, as in the first version of the LineFollower program.

writing the code

Of course, you need to decide what the TriBot’s distance from the wall should be. The TriBot should stay close enough to the wall while still having enough room to turn when it gets to a corner. You can get a reasonable starting value by using the NXT’s View menu and following these steps:

  1. Put the TriBot on the floor next to the wall, and make sure there is enough ...

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.