Venture of Robots

|VEX| How to use an Ultrasonic Range Finder in RobotC.如何使用超声波传感器

This article will guide you to use an Ultrasonic Range Finder.

这篇文章将介绍如何使用超声波传感器。

1 >

On a sonar , there are two 3-pin wires, one for input and another one for output. Both should be plugged into digital ports.

在一个超声波上,有两个3针数据线,一个用于输入,一个用于输出。两条线都应该插入digital口中。

2>

Configure the sensor in Motor and Sensor Setup.

在 Motor and Sensor Setup配置传感器。

You can choose the unit system that you prefer. After choosing the second port will be automatically configured for you.

你可以选择你喜欢的单位制。选择后,第二个端口会被自动配置。

You can put the input/output wire into either one of the configured ports. The orders does NOT influence your codes.

input/output口的插入顺序可以随意,不会影响你的代码。

You can use the code below to read its value.

你可以用下面的代码读取它的值。

你也可以用下面这篇文章的方法读取它的实时值。

You can also read its real-time value by the method mentioned by the article below.

http://alpar.xyz/real-time-observations-of-sensor-values-in-robotc/

We can use sonar to detect obstacles or targets, and adjust robot’s position by detecting the opponent or the distance to the edge of the compound .

Try it out yourself!

我们可以使用超声波传感器去检测物品或障碍,也可以基于它的数据(检测对手的位置或离场地边缘的距离)来调整机器人的位置。

自己尝试吧!

作者/Author :Alpar.

This post is orginal, please remember to mark the source if you want to transfer the content.

这篇文章为原创,转载请标明出处。

 

Leave a Reply

Your email address will not be published. Required fields are marked *