Sometimes we want our robots to have some kind of random behavior. In such cases we need to generate some random values. Now we will take a look at how we can achieve that by using the EV3 programming language.

To access the full video please subscribe to FLLCasts.com
- #932
- 26 Sep 2018
Random block
The Random block is used to generate random values. It is the last block in the data palette and its icon is a dice. Take it and put it on the canvas:
From the drop-down menu we can see that the block has two modes - one for generating random numbers and one for generating random logic values i.e. True or False.
Numeric mode
First, let us take a look at the numeric mode. In that mode the block has two input parameters. The first one is for the lower bound
and the second one is for the upper bound.
The block has also one output parameter. It returns a random number between the lower bound and the upper bound with each number in between with equal probability.
Example
If you take a random block that generates a random number between 1 and 5 and you then pass the result from it to a switch block, which has the following cases:
the result will be as follows:
- if the random block generates 1, the robot will display "one";
- if the random block generates 2, the robot will display "two";
- if the random block generates 3, the robot will display "three";
- if the random block generates 4 or 5, the robot will display "greater than three".
Logic mode
Next, we have the logic mode. As mentioned above, we can randomly generate true or false using the logic mode. In that mode the block has only one parameter.
It is the probability of returning true in percents. The default value is 50 which means that true and false have equal probability. The output parameter returns true or false.
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

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

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

Lesson 1 - Playing with press modules
Introduction to course 4.0
Waiting for translation from Bulgarian
- 5
- 10
- 6
- 3d_rotation 2