Sometimes you need to evaluate the value of a sensor or some other data and depending on the value to execute one action or other. In a way we have achieved that so far, using the switch block, but we have had only two cases - if the statement is true do one thing and if the statement is false do another. However, sometimes we need more than two cases and then we use the switch block as a switch statement.

To access the full video please subscribe to FLLCasts.com
- #1171
- 22 Mar 2019
The switch block can be used as a switch statement with Brick Buttons, Color Sensor, Infrared Sensor, Text and Numeric. For the purpose of this tutorial, we will explore only the switch block using the Numeric mode. First of all, put a switch block and set it to numeric:
As you can see there are two cases - one if the value is 0 and one if the value is 1. If we want to add more cases, we can do it by selecting the plus sign shown bellow:
Afterwards we set the desired value:
The same way using the "x" sign, next to the value for each case
we can remove the corresponding case:
So the switch block evaluates the numeric value and if the value of a given case is the same, it will execute the blocks within the case.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons

Robotics with LEGO - Level 1.5 - Spy games
The second level of the Robotics with LEGO curriculum for students from fifth to twelfth grades.
Students build multiple robots with thread chains and become familiar with the physical concepts of momentum and center of gravity. The concept of gears, their use and basic constructions involving gears are studied.
The new concept of "condition" is introduced in programming. Robots are becoming smarter as they can make complex decisions on their own. "Spy robots" follow their targets and avoid being noticed. This level introduces the light sensor which the robots use to recognize the colors of the objects they are looking for. Robots can stop on a black line and follow a route marked with a colored line on the floor.
The spy's most complex mission in the end of the level is to turn into a sumo wrestler and defeat any other robot in the ring.
- 56
- 12:47
- 136

Robotics with LEGO - Level 3.5 - Measuring tools
The sixth level of the Robotics with LEGO curriculum for students in sixth or seventh grade.
In this level, we introduce student-created myBlocks. Any functionality that is used in several places in a program is grouped into myBlock thus shortening the program's length. Students create blocks that return the result of calculations as an output parameter. Input parameters can change the calculations in the myBlocks. The robot constructions measure physical properties like linear or rotational speed, the fuel level in a tank, or length, area and volume.
- 58
- 0:00
- 185

Robotics with LEGO - Level 4.0 - Kinesthetic and Memory Game (in development)
The seventh level of the Robotics with LEGO curriculum for students in sixth or seventh grade.
In this level, student develop a memory training game. The player must remember series of actions like press a button, shake a pole, pull a lever, show one of many colors. In order to program the game, students use many variables and modify their states. Students create their own custom sounds and images, in order to reflect their own personality in the game. In the end of the level, the game stores top scores even after a full shut down with the help of text files.
- 59
- 2:58
- 200

Припомнете си как се работи с условни оператори и кога се използва
Sometimes you need to evaluate the value of a sensor or some other data and depending on the value to execute one action or other. In a way we have achieved that so far, using the switch block, but we have had only two cases - if the statement is true do one thing and if the statement is false do another. However, sometimes we need more than two cases and then we use the switch block as a switch statement.
- 3
- 0
- 0
- 3d_rotation 0