around the block

The next program will make the TriBot travel around a square and stop where it started. For this example, I’ll use a square that is three rotations long on each side. At the corner, the robot will move in a gentle curve rather than just spinning in place. The robot doesn’t need to hug the edges of the square, just travel around it, and you can get a smoother motion by using a curve instead of spinning.

To travel around a square, the robot needs to move along a side and go around the corner, move along the next side and go around that corner, continuing this for all four sides.

the first side and corner

The first part of the program uses two Move blocks to move the TriBot along the side and make the first turn. Moving along the edge ...

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.