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
  • accelerometer
  • colorSensorR, colorSensorG, colorSensorB
  • gamepadPad1, gamepadPad2
  • gyroscope
  • lineSensor

Was this helpful?

Export as PDF
  1. TRIK controller
  2. Programming TRIK with the visual programming language

Sensory variables for the TRIK controller

PreviousTRIK specific blocksNextTRIK controller programming in Python and JavaScript

Last updated 4 years ago

Was this helpful?

This article is automatically translated from Russian by Google Translator.

Sensor variables are reserved variables for getting readings of the sensors connected to the corresponding ports.

These values can be assigned to variables and used in mathematical expressions.

Variable changes can be tracked as you go through the program in .

Variable

Description

An array of three elements containing accelerometer readings on the X, Y, and Z-axis.

buttonDown

buttonUp

buttonEnter

buttonEsc

buttonPower

buttonLeft

buttonRight

State of the buttons on the TRIK controller body: "Down", "Up",

"Enter", "Esc", "Power",

"Left", "Right".

Possible values: 0 — button not pressed. 1 — button pressed.

The color sensor readings by the camcorder in the center of the frame are the intensity of red, green, and blue, respectively.

They are only updated when the color sensor is turned on and initialized.

Possible values: 0 ... 255

encoder1 encoder2 encoder3 encoder4

Encoder readings on ports E1, E2, E3, E4 respectively.

gamepadButton1

...

gamepadButton5

The state of the buttons on the remote control from 1 to 5 respectively.

0 — the button is not pressed. 1 — button is pressed.

gamepadConnected

Remote control connection status.

0 — remote control is not connected. 1 — the remote control is connected.

The coordinates of pressing the active areas on the remote control.

Each variable stores an array of two elements corresponding to the coordinate of the press point.

Possible values: From (-100, -100) to (100, 100).

(-101, -101) — if there is no press.

gamepadPad1Pressed gamepadPad2Pressed

gamepadWheel

Tilt value of the remote control (if it is connected and the "steering wheel" is enabled on it).

Possible values: -100 ... 100. -101 — if there is no data on the "rudder" position.

-100 — extreme left position. 100 — extreme right position.

An array of three elements containing the gyroscope readings on the X, Y, and Z-axis respectively.

The array of three elements containing the camera readings in the line sensor mode. The values are updated when the line sensor is enabled and initialized.

objectSensorX objectSensorY

The coordinates of the object detected by the video camera in relation to the center of the screen. The values are updated when the sensor is on and initialized.

Possible values: -100 to 100 (relative to the center of the frame).

objectSensorSize

The size of the object recognized by the video camera. The value is updated when the object sensor is activated and initialized.

Possible values: 0 to 100.

100 - object occupies the whole frame.

sensorA1 ... sensorA6

Readings of the sensors connected to the corresponding analog ports.

sensorD1 sensorD2

Readings from sensors connected to the corresponding digital ports.

accelerometer

An array of three elements containing accelerometer readings on the X, Y, and Z axis, respectively.

Example

x = accelerometer[0]; -- X-axis accelerometer readings
y = accelerometer[1]; -- Y-axis accelerometer readings
z = accelerometer[2]; -- Z-axis accelerometer readings

colorSensorR, colorSensorG, colorSensorB

The color sensor readings by the camcorder in the center of the frame are the intensity of red, green, and blue, respectively. They are only updated when the color sensor is turned on and initialized.

Possible values

From 0 to 255.

Example

r = colorSensorR; -- red intensity
g = colorSensorG; -- green intensity
b = colorSensorB; -- blue intensity

gamepadPad1, gamepadPad2

The coordinates of pressing the active areas on the remote control.

Each variable stores an array of two elements corresponding to the coordinate of the click point.

Possible values

From (-100, -100) to (100, 100), (-100, -100) - top left corner of the active area. (-101, -101) - if there is no click.

gyroscope

An array of three elements containing the gyroscope readings on the X, Y, and Z-axis respectively.

Пример

x = gyroscope[0]; -- X-axis gyroscope readings
y = gyroscope[1]; -- Y-axis gyroscope readings
z = gyroscope[2]; -- Z-axis gyroscope readings

lineSensor

An array of three elements containing camera readings inline sensor mode. The values are updated when the sensor is on and initialized.

lineSensor[0]

The deviation of the line from the screen center from -100 (leftmost line position in the frame) to 100 (rightmost line position).

lineSensor[1]

Crossing probability is defined as the percentage of points inside the horizontal stripe in the center of the frame that is recognized as a line, from 0 (no such points) to 100 (all points in the horizontal strip are recognized as a line).

lineSensor[2]

Relative line size, that is, the number of points in the frame defined as a line, from 0 (no line in the frame) to 100 (the whole frame is recognized as a line).

The state of the click on the left and right area of the remote control respectively. The coordinates of pressing can be found out with the help of the variables and . Possible values: 1 — the active area on the remote control is pressed. 0 — the active area on the remote control is not pressed.

accelerometer
colorSensorR
colorSensorG
colorSensorB
gamepadPad1
gamepadPad2
gamepadPad1
gamepadPad2
gyroscope
lineSensor
the variable table