Building Smart LEGO MINDSTORMS EV3 Robots
上QQ阅读APP看书,第一时间看更新

Change to tabbed view

In the top left corner of the switch block, there is a small button that toggles Tabbed View. This compresses the switch slightly so that it only shows one case at a time, and you can switch between the two cases using the tabs at the top of the switch. We will be writing a lot of programming in the true case of the switch, so selecting tabbed view will streamline the program a bit.

Tabbed view does not make any functional change to the program. It is simply for the convenience of the programmer, as it  makes the program appear neater and makes it easier to navigate. 

After selecting tabbed view, the switch will reconfigure itself and the code will look like this:

We have finished the false case of the switch! The robot will check IR 2 to see whether a beacon is present. If there are no nearby beacons, the robot will halt all of its motors and wait until one comes within sight. But what if there is a beacon present? 

Use the tabs at the top of the switch to select the true case. It is now time to start programming the true case: