LogoLogo
TRIK StudioTRIKLego EV3Lego NXT
English
English
  • TRIK help
  • TRIK Studio
    • About TRIK Studio
      • How to find out the version of TRIK Studio
    • Getting started and creating a project
    • TRIK Studio interface
      • TRIK Studio main menu
      • Working with graphs
      • How to open robot settings
      • How to change TRIK Studio interface language
    • TRIK Studio settings
    • 2D model
      • 2D model tuning
      • Adding restrictions to the 2D Model
        • Restrictions setting examples
    • Visual programming
      • Adding and removing blocks
      • Common blocks
      • Links between blocks
      • Syntax of expressions in the blocks
        • TRIK Studio language types
          • Array
        • TRIK Studio language tokens
        • TRIK Studio language operators
        • Constants
        • Sensor variables
        • Built-in functions
      • Property editing
      • Subprograms
    • Textual programming
    • Exercises
    • External tools
      • PuTTY
      • WinSCP
    • TRIK Studio shortcuts
    • Antivirus conflicts
      • Avast antivirus blocks TRIK Studio. What to do?
  • TRIK Studio Junior
    • About TRIK Studio Junior
      • How to find out the version of TRIK Studio Junior
    • Getting started and creating a project in TRIK Studio Junior
    • TRIK Studio Junior interface
      • How do I replace the "Character movement" image?
    • TRIK Studio Junior settings
    • Visual programming in TRIK Studio Junior
      • Adding and removing blocks in TRIK Studio Junior
      • Blocks in TRIK Studio Junior
      • Links between blocks in TRIK Studio Junior
      • Syntax of expressions in the blocks in TRIK Studio Junior
      • Property editing in TRIK Studio Junior
      • Subprograms in TRIK Studio Junior
    • Exercises in TRIK Studio Junior
  • INTEGRATIONS
    • PyCharm
      • Running a 2D model in TRIK Studio from PyCharm
    • Sublime Text
      • Running a 2D model in TRIK Studio from Sublime Text
      • Uploading programs to several TRIK robots from Sublime Text
    • VSCode
      • Running a 2D model in TRIK Studio from VSCode
      • Uploading programs to several TRIK robots from VSCode
  • TRIK controller
    • About the TRIK controller
      • Screenshot of the TRIK controller screen
    • TRIK controller firmware
      • How to find out the firmware version of the TRIK controller?
    • TRIK controller menu
    • Connecting to the TRIK controller via Wi-Fi
      • Connecting the TRIK controller to a computer and smartphone
      • Connecting the TRIK controller to TRIK Studio
      • Interaction of TRIK controllers
        • An example of solving a problem on the interaction of two robots
    • Connecting to the TRIK controller using UART
    • Launching and uploading programs to the TRIK controller
    • Programming TRIK with the visual programming language
      • TRIK specific blocks
      • Sensory variables for the TRIK controller
    • TRIK controller programming in Python and JavaScript
      • Object «brick»
        • Class «accelerometer»
        • Class «battery»
        • Class «colorSensor»
        • Class «display»
        • Class «encoder»
        • Class «gyroscope»
        • Class «keys»
        • Class «led»
        • Class «lineSensor»
        • Class «motor»
        • Class «objectSensor»
        • Class «sensor»
      • Object «script»
      • Object «mailbox»
      • Object «gamepad»
      • Object «Threading»
      • Function getPhoto
      • Function include
    • TRIK controller web interface
    • Connecting devices to TRIK and working with them
      • Connecting and working with the video module
      • Testing devices connected to the TRIK controller
      • Configuring the operation of a USB camera with a TRIK controller
      • Capturing images with TRIK camera and using them in TRIK Studio
      • Working with battery and charger
  • LEGO EV3 Controller
    • About LEGO EV3
    • Connecting a LEGO EV3 Controller to TRIK Studio
    • LEGO EV3 specific blocks
    • Sensory Variables for the LEGO EV3 Controller
    • Launching and uploading programs to the LEGO EV3
  • LEGO NXT Controller
    • About LEGO NXT
    • LEGO NXT Controller Firmware
    • Connecting a LEGO NXT Controller to TRIK Studio
    • LEGO NXT specific blocks
    • Sensory Variables for the LEGO NXT Controller
    • LEGO NXT C Programming
    • Launching and uploading programs to the LEGO NXT
  • Quadcopter Geoscan Pioneer
    • About quadcopter Geoscan Pioneer
    • Geoscan Pioneer specific blocks
  • TRIK Gamepad
    • About TRIK Gamepad
      • TRIK Gamepad App
      • TRIK Gamepad Utility
    • Robot control from the remote control
  • Feedback
    • Actions in case of TRIK Studio or TRIK controller malfunction
    • Ask a Question
    • trikset.com
Powered by GitBook
On this page
  • Algorithms
  • Initial Node
  • Final Node
  • Variable Initialization
  • Condition
  • End if
  • Pre-conditional Loop
  • Loop
  • Switch
  • Expression
  • Subprogram
  • Fork
  • Join
  • Kill thread
  • Random Initialization
  • Comment
  • Actions
  • Send Message To Thread
  • Get Button Code
  • Forward
  • Backward
  • Turn right
  • Turn left
  • Say
  • LED
  • Waiting
  • Timer
  • Receive Message From Thread
  • User input
  • Wait for Button
  • Drawing
  • Clear Screen
  • Marker Down
  • Marker Up
  • Print Text
  • Painter Color
  • Painter Width
  • Draw Pixel
  • Draw Line
  • Draw Rectangle
  • Draw Ellipse
  • Draw Arc
  • Smile
  • Sad Smile
  • Background Color

Was this helpful?

Export as PDF
  1. TRIK Studio Junior
  2. Visual programming in TRIK Studio Junior

Blocks in TRIK Studio Junior

PreviousAdding and removing blocks in TRIK Studio JuniorNextLinks between blocks in TRIK Studio Junior

Last updated 3 years ago

Was this helpful?

This article is automatically translated from Russian by Google Translator.

TRIK Studio Junior blocks consist of four categories:

  1. — blocks to describe algorithms.

  2. — blocks that perform any action on the "Character movement": commands to drive forward, turn, play sound, and others.

  3. — blocks waiting for an event to occur: certain sensor readings, pressing a button, etc.

  4. — blocks displaying graphics and text on the screen.

Algorithms

Icon

Name

Description

The starting point for program execution.

Each diagram should have only one such block. There should not be any incoming links in it, and there should be only one outgoing link from this element.

The process of diagram interpretation begins with this block.

End of the program.

If the program consists of several parallel execution sections, reaching this block completes the corresponding execution section.

This block cannot have outgoing links.

A block for declaring a new variable and setting a value for it.

Separation of program execution in accordance with a given condition.

Indicates merging of two branches of a conditional statement. It does not perform any actions but is useful for ensuring the structure of the program.

A loop that is executing so far some condition is true, indicated before it begins. This condition is checked before the loop body is executed, so the body may not be satisfied even once (if the condition is false from the very beginning).

Block that provides the execution of a sequence of blocks several times.

A condition with several alternatives.

Counts the value of the specified expression. Initialization of variables is also allowed.

Subprogram execution.

Block divides program execution into several threads.

Block merging parallel tasks.

Finishes the task with the identifier specified in the "Task" property. Must be applied from another task.

A block for assigning a specified variable to a random integer from a given interval.

Block for adding arbitrary text to the diagram as a comment.

Initial Node

The starting point for program execution.

Each diagram should have only one such block. There should not be any incoming links in it, and there should be only one outgoing link from this element.

The process of diagram interpretation begins with this block.

Final Node

End of the program.

If the program consists of several parallel execution sections, reaching this block completes the corresponding execution section.

This block cannot have outgoing links.

Variable Initialization

Properties

Property

Description

Value

An expression is specified that defines the initial value of the variable.

Variable

The variable name is specified.

Condition

Separation of program execution in accordance with a given condition.

This block must have two outgoing connections, at least one of which must have the value of the Condition parameter set: true or false.

Properties

Property

Description

Condition

End if

Pre-conditional Loop

A loop with a precondition is a loop that is true so far for some conditions specified before it starts. This condition is checked before the loop body is executed, so the body may not be satisfied even once (if the condition is false from the very beginning).

Properties

Property

Description

Condition

Loop

Block that provides the execution of a sequence of blocks several times. The number of repetitions is set by the value of the Iteration parameter. The block must have two outgoing connections, one of which must be marked with the value “body” (that is, the value of the “Condition” parameter the connection must have “body”). Another connection coming from the “Cycle” block should remain unmarked: it will go through when the program passes through the “Loop” block the specified number of times. Infinite loops and loops of the form while / do and while are organized without using this block, looping the control flow using links. An exit from such a loop is carried out using the “Condition” block.

Switch

A condition with several alternatives.

This block must have several outgoing links. All relations, except one, should be marked with an elementary value (string, number, etc.), which can take an expression (the value is simply written in the Condition property of the connection). One of the links should not be marked: it jumps if the expression is not equal to any of the listed values.

Expression

Evaluate the value of the specified expression. Initialization of variables is also allowed.

Subprogram

Subprogram execution. Subprograms are used to keep repeating program fragments on a separate diagram. When adding this block to the diagram, you will be prompted to enter the name of the subprogram, after which double-clicking on the block will be able to go to the diagram corresponding to this subprogram. An additional palette with all the subprograms will also appear. Subprograms from it can be dragged onto the scene and used as normal blocks. The appearance, name, and properties of the block can be changed using the context menu.

Properties

Changing the properties of this block does not perform in the "Properties Editor" panel, but using the "Change Properties" item in the context menu. To call the context menu, right-click on the block "Subprogram".

In the window that opens, you can:

  • Change subprogram name.

  • Add and change subprogram parameters by specifying a name, type, and value.

  • Change the picture on the icon of your subprogram.

  • Change subprogram icon background.

Fork

Join

Block for merging parallel tasks.

It blocks the execution of the program until the execution of all parallel tasks included in this block reaches this block.

A block must have at least two incoming links. On the outgoing connection (in the “Condition” property) there must be an identifier for the task, which will continue after the block has completed.

Kill thread

Finishes the task with the identifier specified in the "Task" property. Must be applied from another task.

Random Initialization

A block for assigning a specified variable to a random integer from a specified interval using the From and To properties.

Comment

Block for adding arbitrary text to the diagram as a comment.

Used to explain a specific block or section of a diagram. May be associated with the block, which he explains.

When the program is executed, the block is not taken into account.

Actions

Icon

Name

Description

Sends the message to the parallel thread with the identifier given.

Saves the code of the button pressed on the robot to the specified variable.

Moves the "Character movement" forward by the specified number of cells.

Moves the "Character movement" back by the specified number of cells.

Turns "Character movement" to the right.

Turns "Character movement" to the left.

Speak through the speaker the phrase passed as an argument.

Set the specified controller's LED color.

Send Message To Thread

Sends the message to a parallel task with a specified identifier (the identifier must be specified while creating the task in the "Fork" block).

The message can be arbitrary.

Get Button Code

Assigns the pressed button code to a specified variable.

The "Waiting" property allows you to wait for the button to be pressed. If the button is not pressed, the variable will be set to -1.

Forward

Moves the "Character movement" forward by the specified number of cells.

The "Number of cells" property allows you to set the number of cells the "Character movement" should move by.

Backward

Moves the "Character movement" back by the specified number of cells. The "Number of cells" property allows you to set the number of cells the "Character movement" should move by.

Turn right

Turns "Character movement" to the right.

Turn left

Turns "Character movement" to the right.

Say

Use the speaker to say the phrase passed as the block argument.

LED

Set the specified LED color on the controller.

Waiting

Icon

Name

Description

Block for setting the delay. The delay time is set in the Delay parameter in milliseconds.

Wait for a message from another parallel task.

Wait for the user to enter a value.

Wait until the specified button on the robot is pressed.

Timer

Block for setting the delay. The delay time is set in the Delay parameter in milliseconds.

Receive Message From Thread

Wait for a message from another parallel task.

The message text will be assigned to the specified variable.

The "Wait for message" property allows you to specify what to do if the message queue is empty: wait for a new message to arrive or continue working by assigning an empty string to the variable.

The message is automatically converted to the same type as the receiver variable. For example, if you send a number as a string, it will be accepted as a number.

User input

Wait for the user to enter a value. The value will be assigned to the specified variable.

Properties

The block has three properties:

Property

Description

Variable

Variable name.

Default

Default variable value.

Text

Text field description.

Example

Block

Execution

Wait for Button

Wait until the specified button on the robot is pressed.

Drawing

Icon

Name

Description

Erase everything that is drawn on the screen.

Start drawing with a marker of a given color on the floor. When the robot moves in a two-dimensional model, a colored line will remain behind it.

Finish drawing with a marker.

Print the specified string at the specified location on the robot's screen. The default value of the "Text" property is interpreted as a pure string, so it will be displayed that way.

Specify the color to draw simple graphical shapes on the robot's screen.

Specify the line width used to draw simple graphical figures on the robot's screen.

Draw a dot on the screen at the specified coordinates.

Draw a line segment on the screen. Segment ends are given as parameters to the block.

Draw a rectangle on the screen. The coordinates of the upper left corner, the width, and the height of the rectangle are specified as parameters.

Draw an ellipse inscribed in a given rectangle on the screen.

Draw an arc on the screen, given the coordinates of the rectangle in which it will be inscribed, and the angles (in degrees) of its beginning and end on the circle. If the beginning and the end coincide, the circle will be drawn.

Draw a smiley face on the screen.

Draw a sad smiley face on the screen.

Set the screen background color.

Clear Screen

Erase everything that is drawn on the screen.

Marker Down

Start drawing with a marker of a given color on the floor. When the robot moves in a two-dimensional model, a colored line will remain behind it.

The block is available only in the two-dimensional model mode.

Marker Up

Finish drawing with a marker.

The block is available only in the two-dimensional model mode.

Print Text

Prints the specified string at the specified location on the robot's screen.

Properties

Property

Value

Evaluate

True — print the variable or expression value.

False — print as text.

Text

Text or variable/expression to be printed.

Redraw

True — redraw the screen. False — do not redraw.

X, Y

The text beginning coordinates.

How to print a text?

To print a text:

  1. Put your text into the Text property.

  2. Uncheck the Evaluate checkbox.

How to print a variable value?

To print a variable value:

  1. Put the variable name into the Text property.

  2. Check the Evaluate checkbox.

Painter Color

Specify the color to draw simple graphical shapes on the robot's screen.

Painter Width

Specify the width of the line used to draw simple graphical figures on the robot's screen.

Draw Pixel

Draw a dot on the screen at the specified coordinates.

Draw Line

Draw a line segment on the screen. Segment ends are given as parameters to the block.

Draw Rectangle

Draw a rectangle on the screen. The coordinates of the upper left corner, the width, and the height of the rectangle are specified as parameters.

Draw Ellipse

Draw an ellipse inscribed in a given rectangle on the screen.

Draw Arc

Draw an arc on the screen, given the coordinates of the rectangle in which it will be inscribed, and the angles (in degrees) of its beginning and end on the circle. If the beginning and the end coincide, the circle will be drawn.

Smile

Draw a smiley face on the screen.

Sad Smile

Draw a sad smiley face on the screen.

Background Color

Sets the screen background color.

A block for declaring a new variable and setting a value for it. The same operation can be performed using the block, but this block makes the program more clear.

A logical expression is indicated (for more details, see the article ""), based on the value of which the further path of the diagram execution will be selected.

Indicates merging of two branches of a conditional statement. It does not perform any actions but is useful for ensuring the structure of the program. It does not perform any actions but is useful for ensuring the structure of the program. If you adhere to the rule that all branches of the "" or "" operators converge on such a block, this will significantly increase the chances that the generator will be able to generate code in text language without goto statements.

The logical expression is specified (for more details, see the article ""), based on the value of which the further path of the diagram interpretation will be selected.

In the "Expression" parameter, you can specify an arbitrary expression (for more details, see the section ""), based on the value of which the further path of the diagram interpretation will be selected.

For more information about the syntax of valid expressions for the Expression parameter, see the section "".

A block divides program execution into several threads. For example, you can simultaneously wait for the sensor to trigger and the time interval to expire. A block must have at least two outgoing connections. In order to be able to further refer to parallel tasks generated by this block (for example, in the "" block or in the "" block), you need to give the names of the tasks. This is done on outgoing connections, in the Condition property. The name of the task can be any string, but one of the names should be the name of the task that is included in this block. The name of the main program is main.

Syntax of expressions
Expression syntax
Algorithms
Actions
Waiting
Drawing
Expression
Condition
Switch
Kill thread
Join
Expression Syntax
Syntax of expressions
Initial Node
Final Node
Variable Initialization
Condition
End if
Pre-conditional loop
Loop
Switch
Expression
Subprogram
Fork
Join
Kill thread
Random Initialization
Comment
Send Message To Thread
Get Button Code
Forward
Backward
Turn right
Turn left
Say
LED
Timer
Receive Message From Thread
User input
Wait for Button
Clear Screen
Marker Down
Marker up
Print Text
Painter Color
Painter Width
Draw Pixel
Draw Line
Draw Rectangle
Draw Ellipse
Draw Arc
Smile
Sad Smile
Background Color
Initial Node
Final Node
Variable Initialization
Condition
End if
Pre-conditional Loop
Loop
Switch
Expression
Subprogram
Fork
Join
Kill thread
Random Initialization
Comment
Send Message To Thread
Get Button Code
Forward
Backward
Turn right
Turn left
Say
LED
Timer
Receive Message From Thread
User input
Wait for Button
Clear Screen
Marker Down
Marker Up
Print Text
Painter Color
Painter Width
Draw Pixel
Draw Line
Draw Rectangle
Draw Ellipse
Draw Arc
Smile
Sad Smile
Background Color