# 超声波传感器

## 功能简介

RGB超声波传感器是一款将RGB灯珠和超声波测距模块集成在一起的全新模块。它只需要一个GPIO即可操作超声波收发，另一个GPIO用来调节彩灯颜色。在超声波探头测距的同时，左右探头可以发出7彩炫彩灯光。

<figure><img src="/files/JGF2EztZvTVVvqRmmH5f" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
之前采用的硬件版本如下：

<img src="/files/TVQbIVbvCoVMikvIah6K" alt="" data-size="original">
{% endhint %}

## 硬件设置

使用电线连接到 NyBoard，如下图所示：

<figure><img src="/files/wwkYvtKTvLg0mKsDOzKg" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
之前采用的硬件版本如下：

<img src="/files/aaX5ShINKGj3S2DM47C3" alt="" data-size="original">
{% endhint %}

具体使用时，将超声波传感器[固定到Nybble的眼部](https://www.bilibili.com/video/BV13A411J75F)。

{% embed url="<https://www.youtube.com/watch?v=kV2UYbpfGic>" %}

## 软件设置

{% hint style="info" %}
目前只支持产品**Nybble**，软件版本**2.0**，模式可选择“**超声波**”或“**随机\_超声波**”。
{% endhint %}

* 您可以使用 Petoi 桌面应用程序中的[固件上载](https://docs.petoi.com/v/chinese/zhuo-mian-ying-yong/gu-jian-shang-zai)完成配置并上传主功能程序。如下图所示：

<figure><img src="/files/B6SDecf2fbcEhps4Hdm1" alt=""><figcaption></figcaption></figure>

* 您也可以使用 [Arduino IDE](https://www.arduino.cc/en/software) 自由地上传程序和修改代码。

请使用最新的 OpenCat 代码完成设置后并上传程序，如下图所示：

![](/files/cw51RPDgxR2IYwXbZgtg)

如果你已经上传了最新的 OpenCat 程序可以让 Nybble 行走，你只需要删除 OpenCat.ino 中 **`#define ULTRASONIC`** 前面的代码注释符号（//）, 如上图所示，然后上传程序即可。

如果您不确定，您需要按照[标准上传程序流程](https://docs.petoi.com/v/chinese/arduino-ide/wei-nyboard-shang-chuan-cheng-xu)上传一遍程序以确保一切配置正确，然后再按照上述步骤上传程序。

如果超声波模块程序正确上传，您可以在 Arduino IDE 的[串口监视器](https://docs.petoi.com/v/chinese/arduino-ide/chuan-kou-jian-shi-qi)中看到相关打印信息，如下图所示：

<figure><img src="/files/x2j4R3BmXmyV23g4Kn20" alt=""><figcaption></figcaption></figure>

超声波模块程序实现功能：根据超声波模块实时监测到的不同距离，超声波模块内部探头亮不同颜色的灯光，Nybble同时会做出不同的动作反应。

功能演示视频如下：

{% embed url="<https://www.bilibili.com/video/BV1GL4y177SR?spm_id_from=333.999.0.0&vd_source=9b8c824ea471803fbf4083a58be25f2c>" %}


---

# 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://docs.petoi.com/chinese/kuo-zhan-mo-kuai/chao-sheng-bo-chuan-gan-qi.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.
