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

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.