Skip to Main Content
The Art of LEGO MINDSTORMS NXT-G Programming
book

The Art of LEGO MINDSTORMS NXT-G Programming

by Terry Griffin
August 2010
Intermediate to advanced content levelIntermediate to advanced
288 pages
13h 21m
English
No Starch Press
Content preview from The Art of LEGO MINDSTORMS NXT-G Programming

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. ...

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.
Start your free trial

You might also like

The Art of LEGO MINDSTORMS EV3 Programming (Full Color)

The Art of LEGO MINDSTORMS EV3 Programming (Full Color)

Terry Griffin

Publisher Resources

ISBN: 9781593272180Errata