So far we have created programs that have two outcomes. For that purpose, we have used a switch block. We set some condition and based on its outcome we either do one action or other. Now, we will take a look at how we can program the robot to have 3 or more different responses to the environment.

To access the full video please subscribe to FLLCasts.com
- #893
- 30 Mar 2018
Let us take the example with the 3-state line following with the following setup:
So, if we put just a switch block that compares whether the value read by the color sensor is less than 27:
the robot will not know what to do in case the value is greater than 27. If the value is less than 27, it is obvious that the robot should turn right. However, in that case, when the value isn't less than 27, the robot has to either go straight forward or turn left. If the value is less than 43, the robot should go straight, but if it is greater, then it should turn left. How can the robot decide what to do?
The same way it has made the decision to turn right - with another switch block. If we put another switch block comparing the value to 37, we will have our issue resolved. Due to the fact that the second switch is evaluated only if the first one is false, when comparing to 43 we know that the value is greater or equal to 20.
The use of switch inside another switch is called nested switch.
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.
- 136
- 280:11
- 156

Competition programming
In this episode, we introduce a LEGO Mindstorms EV3 version of competition robot construction. It is a modular construction, with medium motor for additional attachments and two light or colour sensors for orientating on the field.
- 7
- 0
- 8
- 3d_rotation 1

Level D2. "Seafaring". Robotics with LEGO
The eighth level of the Robotics with LEGO curriculum for students in third or fourth grade.
In this level, students learn to use the fourth sensor in the robotics set - the gyro sensor. The robots are modeled after boats, yachts, and ships. With the help of the gyro sensor, students can set a course for their robots to a given angle and can detect deviations from the course. In open seas, there may be sea-monsters and the robots are being programmed to detect a sudden change in acceleration with the help of the said sensor.
- 24
- 2:49
- 107

Lesson 6 - Catching the wind
In the next lesson we usually do a graduation. Write down your impressions about the students and the reasons why they have the grades you gave them.
- 3
- 5
- 9
- 3d_rotation 1

Level C1. "Transportation". Robotics with LEGO
This is the fifth level in the Robotics with LEGO curriculum for students in third or fourth grade.
For the first time robots with steering wheels are built in this level. Those robots use one or two drive motors. The work of the differential and its usage in vehicles is explored. Students learn in-depth the working of the light sensor to create better line-following programs. The first two-wheeled motorcycle-robot is built.
- 33
- 1:03
- 110

Lesson 5 - Boat for line following with 3 states
Returning feedback to students is important. We try to return feedback constantly in the classes. You should also try to return feedback in a structured way - in a form of a digit. Today you will have to grade your students following this article.
- 5
- 3
- 8
- 3d_rotation 1

Robotics with LEGO - Level 2.0 - Robots in Factories
The third level of the Robotics with LEGO curriculum for students from fifth to twelfth grades.
Robots in this level use two or three sensors at a time and students create more complex programs for them. The work of the differential and its usage in vehicles with one drive motor is explored. Robots interact with each other and transfer information or material between themselves. Students learn in depth how to create smoother line-following programs. In the end of the workday, robots leave the conveyor belt and relax with a recreational game of volleyball.
- 44
- 15:01
- 129

Additional tasks for the warehouse robots
It appears we have more time to work on improvements
- 2
- 1
- 3
- 3d_rotation 0

Robotics with LEGO - Level 2.0 - Robots in Factories
The third level of the Robotics with LEGO curriculum for students from fifth to twelfth grades.
Robots in this level use two or three sensors at a time and students create more complex programs for them. The work of the differential and its usage in vehicles with one drive motor is explored. Robots interact with each other and transfer information or material between themselves. Students learn in depth how to create smoother line-following programs. In the end of the workday, robots leave the conveyor belt and relax with a recreational game of volleyball.
- 44
- 15:01
- 129

Lesson 5 - Robo Car
Returning feedback to students is important. We try to return feedback constantly in the classes. You should also try to return feedback in a structured way - in a form of a digit. Today you will have to grade your students following this article.
- 6
- 4
- 11
- 3d_rotation 1

Robotics with LEGO - Level 2.5 - Maritime Journey
The fourth level of the Robotics with LEGO curriculum for students from fifth to twelfth grades.
In this level students focus on the rotational sensor that is part of every motor in the robotics set. Students also learn to use the fourth sensor in the robotics set - the gyro sensor.
First few robot constructions imitate sea-animals and their behavior. Students create programs that check whether the robot's claws or pecks have successfully caught an object. That sensor in the motors allows the robots to go back in their lairs even after the use of unlimited movement. The rest of the robots are modeled after boats, yachts, and ships. With the help of the gyro sensor, students can set a course for their robots to a given angle and can detect deviations from the course. In open seas, there may be sea-monsters and the robots are being programmed to detect a sudden change in acceleration with the help of the said sensor.
- 42
- 3:52
- 133

Lesson 5 - Personal Yacht
Returning feedback to students is important. We try to return feedback constantly in the classes. You should also try to return feedback in a structured way - in a form of a digit. Today you will have to grade your students following this article.
- 7
- 3
- 10
- 3d_rotation 0

Robotics with LEGO - Level 2.5 - Maritime Journey
The fourth level of the Robotics with LEGO curriculum for students from fifth to twelfth grades.
In this level students focus on the rotational sensor that is part of every motor in the robotics set. Students also learn to use the fourth sensor in the robotics set - the gyro sensor.
First few robot constructions imitate sea-animals and their behavior. Students create programs that check whether the robot's claws or pecks have successfully caught an object. That sensor in the motors allows the robots to go back in their lairs even after the use of unlimited movement. The rest of the robots are modeled after boats, yachts, and ships. With the help of the gyro sensor, students can set a course for their robots to a given angle and can detect deviations from the course. In open seas, there may be sea-monsters and the robots are being programmed to detect a sudden change in acceleration with the help of the said sensor.
- 42
- 3:52
- 133

Lesson 6 - Catching the wind
In the next lesson we usually do a graduation. Write down your impressions about the students and the reasons why they have the grades you gave them.
- 4
- 5
- 11
- 3d_rotation 1

Stay @ Home SPIKE Prime Course
An introduction to the SPIKE Prime set! In this course you will have access to 7 3D instructions for SPIKE Prime robots, exploring the possibilities of the base set. After you build them, you can give them life using our cool programs that do various things, from just moving the robot forward, to finding the closest object to it.
After that, if you are up to the challenge, we have prepared some hard additional tasks. They aim to make you research solutions for modifications to the program and the robot. Of course, you can always make your own additions to the robots and have fun with it!
- 4
- 0:33
- 27