O'Reilly logo

Programming Lego Mindstorms NXT by Owen Bishop

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Loops

Introduction

A loop repeats a whole program or part of a program. Once the microcontrollers have entered a loop, they read the instructions in the loop over and over again, repeating the actions programmed within the loop. They exit at the end of the loop only when a given condition applies. We find the same sort of thing in a musical score (Figure 4.1).

Figure 4.1. This musical score is an example of a loop that is repeated once. The two pairs of dots on the right tell the musician to go back and play part of the score again. By contrast, a loop block usually repeats more than once, perhaps many times or even “forever.”

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required