EV3 Scratch 指南

EV3 Scratch 指南 > Remote(远程)

Remote 远程

The EV3 has an infrared sensor. We connect it to port 4.
EV3 有一个红外传感器。我们将其连接到端口 4。

The sensor has three functions:
该传感器具有三个功能:

  • proximity  接近
  • remote  远程
  • beacon heading  信标航向
Remote  远程

Here we select remote.
这里我们选择 remote

In order to be able to control multiple robots separately, the remote control has 4 different channels.
为了能够分别控制多个机器人,遥控器有 4 个不同的通道。

The role of the buttons
按钮的作用

In the top icon view you can see the sensor state.
在顶部图标视图中,您可以看到传感器状态。

Remote  远程

When pushing the buttons on the remote control you will get:
按下遥控器上的按钮时,您将获得:

  • 0 : no button  0 : 无按钮
  • 1 : left-top  1:左上
  • 2 : left-bottom  2:左下
  • 3 : right-top  3 : 右上
  • 4 : right-bottom  4:右下
  • 9 : activate beacon button
    9:激活信标按钮

You can also press two buttons at the same time:
您也可以同时按下两个按钮 

  • 5 : top two  5 : 前 2 名
  • 6 : diagonal down  6 : 对角线向下
  • 7 : diagonal up  7:对角线向上
  • 8 : bottom two  8 : 下两个
  • 10 : left two  10 : 左 2
  • 11 : right two  11 : 右 2

Detect a button press  检测按钮按下

When a button is pressed on the remote control, we can play a sound. For exemple for the left side buttons
当按下遥控器上的按钮时,我们可以播放声音。例如左侧按钮

Remote  远程
  • top left : play left
    左上 : 向左播放
  • bottom left : play backwards
    左下 : 向后播放

Push a button and hold it for 2-3 seconds. Then release it. This will activate the no left button pressed event, which should rather be called left button released event.
按下按钮并按住 2-3 秒。然后释放它。这将激活 no left button pressed 事件,该事件应称为 left button released 事件。

Remote  远程

We can program the right side as well.
我们也可以对右侧进行编程。

  • top right : play right
    右上 : 键播放
  • bottom right : play forward
    右下角 : 向前播放
Remote  远程

When one of the right buttons is released we do this:
当释放右侧按钮之一时,我们执行以下作:

Remote  远程

There is one larger button at the top. It activates the beacon and has a toggle function:
顶部有一个较大的按钮。它会激活信标并具有切换功能:

  • pushing it once, turns on the green LED
    按一下,绿色 LED 亮起
  • pushing it again, turns the LED off
    再次推动它,关闭 LED

When pressed, we play the sound activate
按下时,我们播放声音激活

Remote  远程

Controlling the robot  控制机器人

Now we can program the remote unit to control the movement of the robot. We use the left buttons to control the forward/backward movement.
现在我们可以对远程单元进行编程以控制机器人的运动。我们使用左按钮来控制前进/向后移动。

Remote  远程

We use the right buttons to control the left/right movement.
我们使用右侧按钮来控制左/右移动。

Remote  远程

Controlling motor speed  控制电机速度

A more flexible way would be if we could also control the speed. We createa variable speed and set it to 0 initially.
更灵活的方法是我们也可以控制速度。我们创建一个 variable speed 并将其最初设置为 0。

  • the top button increases the speed by 10
    顶部按钮可将速度提高 10
  • the bottom button decreases the speed by 10
    底部按钮可将速度降低 10
Remote  远程

We use the beacon button for the emergency brake.
我们使用信标按钮进行紧急制动。

Remote  远程

And the right side buttons are used to pivot left and right, as long as the buttons are pressed.
只要按下按钮,右侧按钮就用于向左和向右旋转。

Remote  远程