> For the complete documentation index, see [llms.txt](https://docs.petoi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.petoi.com/~/changes/MnaoHQ6wOvffal3XIPZR/extensible-modules/gesture-sensor.md).

# Gesture Sensor

{% embed url="<https://youtu.be/1sznhot5U0E>" %}

{% embed url="<https://youtu.be/namXLL7VmrQ>" %}

## Function introduction

The sensor features advanced gesture detection, proximity detection and digital ambient light sensing. Gesture detection can accurately sense "up, down, left and right" and more complex movements.

<figure><img src="/files/9nQnzPPuxwlYJ87fqwfF" alt=""><figcaption></figcaption></figure>

## Software setup

Install the latest version of the **Arduino\_APDS9960** library using the [Arduino IDE](https://www.arduino.cc/en/software).

<div><figure><img src="/files/mY52WauxhYpyNkmamSAq" alt=""><figcaption></figcaption></figure> <figure><img src="/files/U5gTqPNCTTFBy5t7JcLr" alt=""><figcaption></figcaption></figure></div>

The code using this sensor has been integrated into the [**OpenCat**](https://github.com/PetoiCamp/OpenCat) (NyBoard)/ [**OpenCatEsp32**](https://github.com/PetoiCamp/OpenCatEsp32) (BiBoard) project. Uncomment the line **`#define GESTURE`**  in the **OpenCat.ino / OpenCatEsp32.ino**, as shown in the figure below, and then use the [Arduino IDE](https://www.arduino.cc/en/software) to upload the sketch to the robot main board, which can reproduce the example function of integrating the robot action.

### NyBoard

#### Prepare the Arduino UNO development environment

With **NyBoard V1\_\***, you can simply choose **Arduino Uno**.&#x20;

<figure><img src="/files/4JBNM8f9Sdm40i7VCH7O" alt=""><figcaption></figcaption></figure>

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

### BiBoard

#### [Prepare the ESP32 development environment](https://docs.petoi.com/arduino-ide/upload-sketch-for-biboard#2.1-prepare-the-esp32-development-environment)

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

If you want to test the function of a gesture sensor alone or want to learn more about its principles. You can use the Arduino IDE to upload the demo sketch(**gesture.ino**), as shown below:

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

## Hardware setup

* NyBoard

After uploading the sketch, connect to the NyBoard with wire, as shown in the following picture:

<figure><img src="/files/1RHiTFCW8uuI1w76U1mi" alt=""><figcaption></figcaption></figure>

* BiBoard

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

For specific use, the end connected to the sensor can be fixed on the robot's head (included in Bittle's mouth or attached to the top of Nybble's head); of course, you can also use your creativity according to your needs.

This demo sketch (gesture.ino) implements real-time printing of various directional gestures (up, down, left, and right) made by the user in front of the gesture sensor in the [serial monitor](https://docs.petoi.com/arduino-ide/serial-monitor).

<figure><img src="/files/2IZJ4tVMV9wk3Axrs0ag" alt=""><figcaption></figcaption></figure>

### The demo code

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.petoi.com/~/changes/MnaoHQ6wOvffal3XIPZR/extensible-modules/gesture-sensor.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
