Chapter 6. program flow

Program flow is about controlling the order in which your programming blocks are run. Typically, the blocks run from left to right, but you can control the flow of the program by making blocks wait, repeat, or choose an action based on some condition. The three main blocks used for program flow are the Wait, Switch, and Loop blocks.

You’ve already seen how the Wait block works. In this chapter, I’ll cover the Switch and Loop blocks in depth. The Loop Interrupt block is also used to control Loop blocks, so I’ll explain that as well.

Note

The Switch and Loop blocks also have some features that are used exclusively with data wires, which will be covered in Chapter 9 and Chapter 10.

the switch block

The Switch block (shown in

Get The Art of LEGO MINDSTORMS EV3 Programming (Full Color) 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.