Knowledge Base

If Block

output-onlinepngtools__231_.pngspike_robot.jpg This block works for EV3, Spike and Ruby Robot!  output-onlinepngtools__101_.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.




Parameter Description Compatible Blocks


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.


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


Please sign in to leave a comment.