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

avoiding a busy loop

If you watch closely, you may notice that after you add the code to display the motor position, the AroundTheBlock program doesn’t get the TriBot back to the starting point as accurately as the original program did. The problem is that the Move blocks on the top Sequence Beam are a little less accurate in the new program because the NXT is spending about half its time displaying the motor position.

The code to display the motor position is an example of a busy loop, one that repeats as fast as possible and consequently uses a large portion of the NXT’s processing power. You can improve the accuracy of the Move blocks by slowing down the display loop, which will allow the NXT to spend more of its time making sure the movements ...

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