if

Description

The if judgment block decides whether to run a program based on the condition's truthfulness or chooses to run different programs according to the situation.

if Determines if a condition is true. If so, it executes the program to the right of Do.

if else Determines if a condition is true. If so, it executes the program to the right of Do; if not, it executes the program to the right of else.

true A Boolean value can replace the condition expression. Setting it to true means the condition is met; setting it to false means it is not.

How to Use

Add the if block to your program, add a condition, and add the programs to be executed when the condition is met or not met. For example, light up the RGB bar when the M5GO is standing.

Logic

Description

Logical expressions are often used as conditions in if judgments, comparing data on both sides of the operation to determine if the relationship is correct, ultimately resulting in true or false values for use in if judgments.

How to Use

Create a relationship with data and connect it to the if block as a condition. For example, light up the RGB bar when the gyroscope's X-coordinate is greater than 90.

Logic Operation

Description

Performs logical operations of "and, or, not" on two logical expressions.

and The result of the logical operation is True only if both logical expressions are true; otherwise, it is False.

or The result of the logical operation is True if at least one of the logical expressions is true; otherwise, it is False.

not Inverts the logical result of an expression, i.e., notTrue=False, notFalse=True.

How to Use

Add the relationship expressions to be logically operated on both sides and modify the operation type.

Repeat

Description

As the name suggests, a conditional loop is a loop that requires certain conditions to be met. When our set conditions are met, the loop runs the program content inside the block.

repeat n times Set the number of loops.

repeat while Determines if a condition is met. If so, it loops indefinitely.

How to Use

Add repeat to the program, set the loop count (condition), and add the program to be looped.

Iteration

Description

In simple terms, data iteration is the process of assigning a sequence of numbers, one after another, to the same variable, running the do content once for each assignment.

for each item i in list Sequentially iterates the contents of an array to the variable i, running the do content once for each iteration.

count with i from a to b by c Increases from a to b, with each increase by c, and iterates each result to the variable i, running the do content once for each iteration.

break out of loop Allows for exiting the entire loop or just the current iteration when this block is executed.

How to Use

Add an iteration block to the program, set iteration parameters, and the do program to be run with each iteration. For example, iterate the brightness of the RGB bar from 0 to 100.

Functions

What is a Function?

A function is like a package. We can name a function and place a program inside it. When the function is called, it runs the program it contains. Using functions can save program length, make the program clearer and more

concise, and facilitate modifications when multiple sections of the program are repeated.

Creating Functions

Click on the Functions option, drag the function body to the programming area, change the function name, and place the program inside.

Using Functions

After adding the function body to the programming area, a function call block will appear in the Functions option. Add it to your program.

On This Page