# Robot control from the remote control

{% hint style="info" %}
This article is automatically translated from Russian by Google Translator.
{% endhint %}

To control the robot with the [remote control](/en/gamepad/about.md) you need to write a program and run it on the robot.

## Example of interaction with the remote control

1. Write [an algorithm](/en/gamepad/remote-control.md#program-algorithm) to use the controller in TRIK Studio.
2. [Connect](/en/trik/wi-fi.md) the controller to the computer and [upload](/en/trik/run-upload-programs.md) the written program to the robot.
3. Connect your smartphone to the controller by selecting the controller's network.
4. Open the [TRIK Gamepad](/en/gamepad/about/app.md) app on your smartphone.
5. Execute the algorithm on the controller.

## Program algorithm

1\. Enter variables for gamepad touch coordinates - `x` and `y` - and initialize them by assigning zero values to them in the "[Expression](/en/studio/programming-visual/blocks.md#expression)" block:

![](/files/-MSkriMZXSuzOft8LXet)

2\. Add the "[Wait for Gamepad Connect](/en/trik/programming-visual/blocks.md#wait-for-gamepad-connect)" block:

![](/files/-MSkrlqM10Vs4W2IT6Qq)

3\. To check if the gamepad clicks on the left area (Pad1), add a "[Condition](/en/studio/programming-visual/blocks.md#condition)" block with the condition [`gamepadPad1Pressed`](/en/trik/programming-visual/sensory-variables.md#gamepadpad-1-pressed-gamepadpad-2-pressed)`> 0`:

![](/files/-MSkrpsmBpCdWZIbyqPi)

4\. In case there is no touch, it is necessary to stop the motors. To do this, add a block "[Stop motors](/en/trik/programming-visual/blocks.md#stop-motors)":

![](/files/-MSkrtxleIe9Zw-Nzo3t)

5\. If the [Pad1](/en/gamepad/about/app.md) area is pressed on the gamepad, you need to get the coordinates of the touch. To do this, use the [`gamepadPad1`](/en/trik/programming-visual/sensory-variables.md#gamepadpad-1-gamepadpad2) array in the "[Expression](/en/studio/programming-visual/blocks.md#expression)" block:

![](/files/-MSks4S67RfcXPOFs7sG)

6\. After getting the coordinates, add a simple controller with the "[Motor Forward](/en/trik/programming-visual/blocks.md#motors-forward)" blocks. The Y coordinate offset is responsible for the speed of the robot and the X coordinate offset is responsible for the rotation.

![](/files/-MSks9jn7gXiwTph39UK)

7\. To close the condition, add a "[Timer](/en/studio/programming-visual/blocks.md#timer)" block with a value of `100 ms` (in the program this is the time for a new call to the remote control).

![](/files/-MSksFI6C6HB1lDHy9DU)

8\. Close the loop on the "Condition" block with a link from the "Timer" block.

![](/files/-MSksJbFmzY1gwIshaWV)

9\. If you have a video camera, add the "[Enable Video Streaming](/en/trik/programming-visual/blocks.md#camera-on)" block to the beginning of the program:

![](/files/-MSksQQLNyALYHYJkl_K)

### General view of the algorithm

![](/files/-MSksTiruXVWt_IWcm1Z)

{% hint style="info" %}
You can find the finished program in the root folder of TRIK Studio `/examples/trik/remoteContro`l or download it [here](https://dl.trikset.com/trikset-help/remoteControl.qrs).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.trikset.com/en/gamepad/remote-control.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
