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.


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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.