Edit on GitHub

Task Instructions

Start/End

This instruction establishes the overall beginning and end of a program, and the valid block for the instruction.

Start Program

The following image is an empty Start Program instruction.

End Program

The following is the code that terminates when it reaches to the end.

The following is the code that force terminates at END PROGRAM line.

Begin Block / End Block

The following code shows START PROGRAM and ENDLESS LOOP blocks.

The following code shows START PROGRAM and IF blocks.

The following code shows when the blocks can be omitted.

Comment

The following is an example of inserting a comment to make the source code easier to understand.

Execute

This is an instruction for giving a command to the device or performing a mathematical calculation. Refer to the following figure for details.

Compute

The following is an example of using the Compute instruction.

Load

The following is an example of writing a value to the variable Acceleration, and then reading the variable from the Geared Motor.

The following is an example of setting the speed value of Geared Motor connected to Port 1.

Polynomial

Label/Jump

The following examples show how Label and Jump can be used.

Condition

This instruction controls the flow of program based on the True/False result of Conditional Clause.

Conditional Clause

Operators Description
== The value on the left hand side is equal to the right hand side
!= The value on the left hand side is not equal to the right hand side
> The value on the left hand side is greater than the right hand side
>= The value on the left hand side is greater than or equal to the right hand side
< The value on the left hand side is less than the right hand side
<= The value on the left hand side is less than or equal to the right hand side

More than one condition can be examined as shown below.

Logical Operators Description
then Do not use additional conditional clause.
&& Use logical AND operation for two conditions. Both conditions must be true for the result to be true.
\ Use logical OR operation for two conditions. Either condition must be true for the result to be true.

If

The following is an example of turning the LED on if the variable in the IF statement is equal to 100.

Begin / End Blocks can be omitted when there’s only one instruction in the block.

Else If

The following is an example of using IF and ELSE IF statements.

Begin / End Blocks can be omitted when there’s only one instruction in the block.

Else

The following is an example of using IF, ELSE IF, and ELSE blocks.

Begin / End Blocks can be omitted when there’s only one instruction in the block.

Loop

This instruction is used when the program needs to repeat a specific behavior or to run an instruction multiple times.
The Loop blocks can be configured in various ways by setting a specific condition.

Endless Loop

The following is an example of using Endless Loop to print the number 100 on the screen. The Print Screen with Line command is placed in the ENDLESS LOOP block.

Begin / End Blocks can be omitted when there’s only one instruction in the block.

Loop While

The following is an example of using LOOP WHILE to print the number 100 on the screen for 1.024 seconds.

The following is an example of using LOOP WHILE and a variable to print the number 100 for 10 times.

Loop For

The following is an example of using Loop For to print the number 100 on the screen 10 times.

The following is an example of multiplying the Repeat counter variable by 100 and print on the screen. As the Repeat counter variable increases, the printed value will also be increased by 100; 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000.

Wait While

The following is an example of using WAIT WHILE with a Timer to hold the program running for 1.024 seconds.

The following is an example of using WAIT WHILE with a Motion Status to wait until the motion completes.

The following is an example of using WAIT WHILE with a Buzzer Timer to wait until the melody plays.

Break Loop

The following is an example of using BREAK LOOP to exit the loop when the remote controller data is arrived. After exiting the block, followed by code will be executed.

Function(Sub-Routine)

If a specific code is used repeatedly, or if you wish to classify an area of code as a unit that performs a specific behavior, you can group the lines of code as a Function. Refer to the following figure for details.

Function/Call

The following is an example of making the action of blinking the LED as a function and using it.

The following is the process of selecting a function to call.

Functions cannot call itself within the same function.

Return

The following is an example of a function being executed until the end without using Return.

The following is an example of a function being executed but encountering Return in the middle of executing the function, which will make the program exit the function.

Callback

The following is an example of using the callback function to receive wireless data and save it to the variable “received data”.