adding some logic to BumperBot
In this section, you’ll make a change to the BumperBot program using the Logic block. Recall that the program keeps the TriBot moving forward until it runs into something. What if you want to limit how long the robot moves forward, perhaps to keep it from wandering too far or just to keep from getting bored? You’ll change the program so that the TriBot stops and turns around if it bumps into something or if it travels for more than 20 seconds.
Figure 14-22 shows the code that moves the TriBot forward. The Move block starts the TriBot moving, and it keeps going until the Loop block ends when the Touch Sensor is pressed.
Figure 14-22. Moving forward until the Touch Sensor is pressed
You already know how to use the Touch ...
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.