The EV3 has an infrared sensor. We connect it to port 4.
EV3 有一个红外传感器。我们将其连接到端口 4。
The sensor has three functions:
该传感器具有三个功能:
Here we select remote.
这里我们选择 remote。
In order to be able to control multiple robots separately, the remote control has 4 different channels.
为了能够分别控制多个机器人,遥控器有 4 个不同的通道。
In the top icon view you can see the sensor state.
在顶部图标视图中,您可以看到传感器状态。
When pushing the buttons on the remote control you will get:
按下遥控器上的按钮时,您将获得:
You can also press two buttons at the same time:
您也可以同时按下两个按钮 :
When a button is pressed on the remote control, we can play a sound. For exemple for the left side buttons
当按下遥控器上的按钮时,我们可以播放声音。例如左侧按钮
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 事件。
We can program the right side as well.
我们也可以对右侧进行编程。
When one of the right buttons is released we do this:
当释放右侧按钮之一时,我们执行以下作:
There is one larger button at the top. It activates the beacon and has a toggle function:
顶部有一个较大的按钮。它会激活信标并具有切换功能:
When pressed, we play the sound activate
按下时,我们播放声音激活
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.
现在我们可以对远程单元进行编程以控制机器人的运动。我们使用左按钮来控制前进/向后移动。
We use the right buttons to control the left/right movement.
我们使用右侧按钮来控制左/右移动。
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。
We use the beacon button for the emergency brake.
我们使用信标按钮进行紧急制动。
And the right side buttons are used to pivot left and right, as long as the buttons are pressed.
只要按下按钮,右侧按钮就用于向左和向右旋转。