the loop block

The Loop block lets you repeat a group of blocks over and over. The condition you set controls the number of times the loop is repeated.

A loop has two parts: the loop body and the loop condition. The loop body is the group of blocks within the loop. The condition tells the Loop block whether to run the loop body again or exit the loop and let the next block start. The condition is always checked after the loop body runs; therefore, the loop body is always run at least once.

As shown in Figure 6-13, the Loop block’s Control item gives you five ways to control how many times the body of the loop is run. Each option is discussed next.

Figure 6-13. Control options for the Loop block

  • Forever. The Loop will continue to run until the program ...

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.