Knowledge Base

If Block

output-onlinepngtools__231_.png  This block works for both EV3 Robot and Ruby Robot!  output-onlinepngtools__101_.png

mceclip0.png

Let’s check out the If block, which is also known as the If... Do block or the If/Else block.

The If block allows you to create conditions in your program. For example, using this block you can introduce the statement, “If the ultrasonic sensor detects a value of 50, drive straight,” into your program. The do commands will only be executed IF the condition is true.

 

Additional Options

Click the If block's blue plus  mceclip7.png  button to add else or else if conditions to the block.

2019-12-22_14-20-20.gif 

 

Configuration

Parameter Description Compatible Blocks

if

Adds a condition after the If parameter.

Blocks are repeated in a loop if the condition is true. 

else if

Defines an alternate condition.

If the alternate condition is true, the commands that follow it are executed.

else

Commands that follow the Else parameter are executed if none of the conditions are true.

 

 

Hints and Tips

You can configure the If block to repeat commands indefinitely by adding a True block as the condition!

Was this article helpful?
0 out of -3 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.

Powered by Zendesk