Switch or two-level controller

We will now use a case structure to add a correction to the turns. In the EV3 language, a case structure or if…then…else statement is called a Switch block. The Switch can be controlled by sensors and other logic statements. Although you typically will have only two cases, you could add several other branches to the case structure. Each branch of the Switch is called a case statement and can contain several programming blocks. We will use the Gyro and rotation sensors to define the case to try and "zigzag" onto the exact 90-degree angle to produce a square. In the following screenshot, you can see the entire code. As this program is extensive, it is worth noting how the wires are used to organize the code into rows, ...

Get Learning LEGO MINDSTORMS EV3 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.