Object «brick»

This article is automatically translated from Russian by Google Translator.

The object "brick" represents the TRIK controller and provides access to the robot devices.

Method

Description

accelerometer

Provides access to the accelerometer.

battery

Provides access to battery information.

colorSensor

Provides access to the color sensor by the camera.

display

Provides access to the display of the robot.

encoder

Provides access to the encoder on the specified port.

getStillImage

Get a photo from the camera as an array of bytes.

gyroscope

Provides access to the gyroscope.

keys

Provides access to the buttons on the body of the robot.

playSound

Play the audio file.

led

Provides access to the LED on the body of the robot.

lineSensor

Provides access to the line sensor by the camera.

motor

Provides access to the motor on the specified port.

objectSensor

Provides access to the object sensor by the camera.

say

Pronounce the string passed as a parameter (in Russian or English).

sensor

Provides access to the sensor on the specified port.

stop

Stops all motors and active sensors, and removes what is drawn on the display.

accelerometer

Provides access to the accelerometer (class "Accelerometer").

Syntax

JavaScript
Python
JavaScript
brick.accelerometer();
Python
brick.accelerometer();

battery

Provides access to battery information (class "Battery").

Syntax

JavaScript
Python
JavaScript
brick.battery();
Python
brick.battery();

colorSensor

Provides access to the color sensor by the camera (class "ColorSensor").

Syntax

JavaScript
Python
JavaScript
brick.colorSensor("video1");
Python
brick.colorSensor("video1");

display

Provides access to the display of the robot (class "Display").

Syntax

JavaScript
Python
JavaScript
brick.display();
Python
brick.display();

encoder

Provides access to the encoder on the specified port (class "Encoder").

Syntax

JavaScript
Python
JavaScript
brick.encoder(portName);
brick.encoder("portName");
Python
brick.encoder(portName);
brick.encoder("portName");

As a parameter, you must specify the port.

Example

JavaScript
Python
JavaScript
brick.encoder(E1); // encoder call on port E1
brick.encoder("E2"); // encoder call on port E2
Python
brick.encoder(E1); # encoder call on port E1
brick.encoder("E2"); # encoder call on port E2

getStillImage

Get a photo from the camera as an array of bytes.

Syntax

JavaScript
Python
JavaScript
brick.getStillImage();
Python
brick.getStillImage();

gyroscope

Provides access to the gyroscope (class "Gyroscope").

Syntax

JavaScript
Python
JavaScript
brick.gyroscope();
Python
brick.gyroscope();

keys

Provides access to the buttons on the robot body (class "Keys").

Syntax

JavaScript
Python
JavaScript
brick.keys();
Python
brick.keys();

led

Provides access to the LED on the robot body (class "Led").

Syntax

JavaScript
Python
JavaScript
brick.led();
Python
brick.led();

lineSensor

Provides access to the line sensor by the camera (class "LineSensor").

Syntax

JavaScript
Python
JavaScript
brick.lineSensor();
Python
brick.lineSensor();

motor

Provides access to the motor (power or servomotor) on the specified port (class "Motor").

Syntax

JavaScript
Python
JavaScript
brick.motor(motorName);
brick.motor("motorName");
Python
brick.motor(motorName);
brick.motor("motorName");

As a parameter, you must specify the port.

Example

JavaScript
Python
JavaScript
brick.motor(M1) // motor call on port M1
brick.motor("M2") // motor call on port M2
Python
brick.motor(M1) # motor call on port M1
brick.motor("M2") # motor call on port M2

objectSensor

Provides access to the object sensor by the camera (class "ObjectSensor").

Syntax

JavaScript
Python
JavaScript
brick.objectSensor();
Python
brick.objectSensor();

playSound

Play the audio file.

Syntax

JavaScript
Python
JavaScript
brick.playSound("filename");
Python
brick.playSound("filename");

As a parameter, you must specify the name of the file with an absolute path or the path relative to the folder trik on the controller.

Warning! The file must be pre-loaded on the controller.

Example

JavaScript
Python
JavaScript
brick.playSound("media/sound.mp3"); // Play the sound.mp3 file in the media folder
Python
brick.playSound("media/sound.mp3"); # Play the sound.mp3 file in the media folder

say

Say the line (in Russian or English).

Syntax

JavaScript
Python
JavaScript
brick.say(string);
Python
brick.say(string);

As a parameter, you must specify a string in English or Russian.

Example

JavaScript
Python
JavaScript
brick.say("Привет, я ТРИК");
Python
brick.say("Привет, я ТРИК");

sensor

Provides access to the sensor on the specified port (class "Sensor").

Syntax

JavaScript
Python
JavaScript
brick.sensor(portName);
brick.sensor("portName");
Python
brick.sensor(portName);
brick.sensor("portName");

As a parameter, you must specify the port.

Example

JavaScript
Python
JavaScript
brick.sensor(A1) // call a sensor on port A1
brick.sensor("A2") // call a sensor on port A2
Python
brick.sensor(A1) # call a sensor on port A1
brick.sensor("A2") # call a sensor on port A2

stop

Stops all motors and active sensors, and removes what is drawn on the display.

Syntax

JavaScript
Python
JavaScript
brick.stop();
Python
brick.stop();