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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access