LEGO Mindstorms


Understanding control flow

What are conditionals?

A conditional is used to explain when an action should be performed based on a certain requirement that is met. For example, if you press left mouse button on Minecraft, then you break a block. Notice how the words if and then are bolded and that is because it is possible to form an if/then statement.

How does that work in Mindstorms?

In Mindstorms, it is very easy to add conditionals. Go to the Orange Tab and select the Switch block. This is what Mindstorms call their conditonals.

Making our first conditional

The first block that connects to the start block is called the loop block. We will be using the brick buttons to determine which sound will be played. To do this, change the button below the loop block and hover over the /“brick buttons/” tab, then over /“measure/”, and finally, click on the /“brick buttons/” option.

The top portion of the loop block, indicates what will happen if a condition is met. For example, the condition we want to satisfy here is if the right button on the EV3 is pressed, then play the note A. The bottom box represents if the condition is not met. For example, in our case, if no button is pressed when the program starts, play a C# tone. 


Make a program that goes straight when you press one button and turns 90 degrees when you press another. Make your robot drive in a square.

Next Lesson: Loops
Report an issue