Today we will focus on another block which will allow our robots to make decisions. This block is in the Flow Control palette and is called “Switch”.

To access the full video please subscribe to FLLCasts.com
- #892
- 12 Dec 2017
Take the block and put it in the program:
This block will form branches in our program. We will set a condition which can be either met or not, either true or false. When the condition is met, one sequence of blocks will be executed, and when not – another one. In our case, when the condition is met, the blocks located in the upper half (marked with a tick) will be executed.
If the condition is not met, the blocks located in the lower half (marked with an X) will be executed.
Let’s now take a closer look at the block when the ultrasonic sensor sets the condition. From the dropdown menu we choose "Ultrasonic Sensor > Compare > Distance Centimeters".
We should first set up the number of the port where the sensor is connected. Then, we should set the condition and finally put the blocks which should be executed in the two different cases.
For example, if we want the robot to go forward if the nearest object is more than 50 cm away and backward if not, the program should look like this:
Try out the program. Notice that the check is immediate and unlike orange wait blocks, there is no waiting here.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons

Instructors Remote Training
If you are working with students and you want to introduce Robotics to your class or you want to mentor a FLL team, but you are insecure about your technical knowledge in the Robotics field, then this is the right place for you. Having in mind teachers' busy schedule, we have design two different schedules and added an option to design one just for you. FLLCasts's Mindstorms EV3 Robotics Online Training is the perfect match for any teacher.
After the completion of each task the participant has to upload his solution for verification.
- 183
- 280:11
- 156

Switch
Today we will focus on another block which will allow our robots to make decisions. This block is in the Flow Control palette and is called “Switch”.
- 7
- 0
- 7
- 3d_rotation 1

Level B1. "Spy gadgets". Robotics with LEGO
The third level of the Robotics with LEGO curriculum for students in second, third or fourth grades.
In these lessons, we stress on more complex and challenging robots. The concept of Condition is introduced. Students learn about physics concepts of inertia and center of mass. Robots with two sensors are built and students program both of them. Programming becomes more complex as robots now can make complex decisions. "Spy"-robots sneakily follow their targets, trying to be undetected.
- 30
- 7:30
- 108

Lesson 2 - Switch
Intro
The job of a spy is to spy! This is why, today we build a spy-robot, which target will be to perform that task incognito.
- 2
- 3
- 3
- 3d_rotation 1

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