O'Reilly logo

Learning LEGO MINDSTORMS EV3 by Gary Garber

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

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, ...

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