My Blocks#
Introduction#
My Blocks is the equivalent to functions in Python. My Blocks group blocks into reusable, efficient sections of blocks designed to perform a specific task. My Blocks can be called multiple times within a program, making project organization easier, and helping to avoid repeated blocks.
define myBlock
myBlock
Parameters |
Description |
|---|---|
block name |
A name you give to your My Block. |
parameters |
Optional. Variables that accept input values when the function is called, allowing data to be passed into the function. It can be a number or Boolean. |
Defining and Calling My Blocks#
My Blocks#
If a My Block does not require input, you can define it without parameters.
define greeting
[Define a My Block to display a message.]
print [Hello!] on console ◀ and set cursor to next row
when started
[Call a My Block to display the message.]
greeting
My Blocks with Parameters#
Parameters let you give a My Block the information it needs to work, such as how many times to complete a sequence of movements. For example, a My Block could use a number parameter to tell the robot how many times to repeat a motion. This lets you use the same My Block in different ways depending on what values you give it.
define repetitions (number) :: custom
[Define a My Block with a parameter.]
repeat (number)
increment [arm v] position by x:[100] y:[0] z:[0] [mm v] ▶
when started
[Call a My Block start incrementing.]
repetitions [4]