# 手势传感器

{% embed url="<https://www.bilibili.com/video/BV1HM4y1d7Ep/?vd_source=2653c3369c56df6df4635a87124da1b4>" %}

## 功能简介

该传感器具有先进的手势检测、接近检测和数字环境光感应功能。手势检测能准确地感应“上下左右 ”以及更复杂的动作。

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

## 软件设置

使用 [Arduino IDE](https://www.arduino.cc/en/software) 安装最新版的Arduino\_APDS9960库，如下图所示：

<div><figure><img src="/files/wpLg2KzxynBQXDWZr35g" alt=""><figcaption></figcaption></figure> <figure><img src="/files/YGAJG2vgd8OYgQ8aI9he" alt=""><figcaption></figcaption></figure></div>

[**OpenCat**](https://github.com/PetoiCamp/OpenCat) 项目代码中目前已经集成了使用此传感器的代码，将**OpenCat.ino** 中&#x7684;**`#define GESTURE`**&#x884C;取消注释，如下图所示,  然后使用 Arduino IDE 将程序上传到机器人主板，可以复现整合了机器人动作的示例功能。

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

如果您想单独测试手势传感器功能，或者想进一步了解其功能实现原理。您可以使用 Arduino IDE 上传示例程序（gesture.ino），如下图所示：

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

## 硬件设置

程序上传完成后，使用电线连接到 NyBoard，如下图所示：

<figure><img src="/files/0qV6kU4uLZri2mYOAD1p" alt=""><figcaption></figcaption></figure>

具体使用时可以将连接传感器的一端固定在机器人的头部（含在Bittle的嘴中，或者顶在Nybble的头部），当然您也可以根据实际需要发挥您的创意。

示例程序（gesture.ino）实现功能：在[串口监视器](https://docs.petoi.com/v/chinese/arduino-ide/chuan-kou-jian-shi-qi)中实时打印出用户在手势传感器前面做出的各种方向手势动作（上下左右）。

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

### 示例程序代码

{% file src="/files/rKu12c76JeAguVdWwhUR" %}


---

# 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/shou-shi-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.
