# Gesture Sensor

## 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="https://3127300255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBR9bYMZnmeFFa1GJLvjM%2Fuploads%2FoTOAuKXLMgvqZjEsFMyl%2FGesture_Sensor.png?alt=media&#x26;token=6af3b359-84ae-46e4-b2fb-a30026036483" alt=""><figcaption></figcaption></figure>

## Software setup

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

<div><figure><img src="https://3127300255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBR9bYMZnmeFFa1GJLvjM%2Fuploads%2FjVnyHRiggC8gSK2YvwND%2Fimage.png?alt=media&#x26;token=70ade8c2-207a-43a8-9588-4b2272f8fb95" alt=""><figcaption></figcaption></figure> <figure><img src="https://3127300255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBR9bYMZnmeFFa1GJLvjM%2Fuploads%2FxMFmwpPdudFfBymLVt4Z%2FAPDS9960%E5%BA%93_en.png?alt=media&#x26;token=14452e52-492f-429f-874d-81282d519f51" alt=""><figcaption></figcaption></figure></div>

2\. Upload the demo sketch (gesture.ino)

<figure><img src="https://3127300255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBR9bYMZnmeFFa1GJLvjM%2Fuploads%2FhIGEVi47DWC8m9a0mpQt%2Fimage.png?alt=media&#x26;token=87b2b722-c730-4b85-a49c-0519256b76c2" alt=""><figcaption></figcaption></figure>

Of course, you can also compile and upload your own sketch for the gesture sensor.

## Hardware setup

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

<figure><img src="https://3127300255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBR9bYMZnmeFFa1GJLvjM%2Fuploads%2F0kgv9DtynA7QZjRGQ6JH%2FGesture_Sensor.jpeg?alt=media&#x26;token=004c6853-6cbf-4202-a38d-93abae04b5b3" 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 actual 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="https://3127300255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBR9bYMZnmeFFa1GJLvjM%2Fuploads%2FEYeHzF47IzhjsWin58r6%2Fimage.png?alt=media&#x26;token=ae21860f-9192-4372-94df-11e6ee79ba67" alt=""><figcaption></figcaption></figure>

### The demo code

{% file src="<https://3127300255-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBR9bYMZnmeFFa1GJLvjM%2Fuploads%2FCYrpHtgSTJ4SG3uBXDqX%2Fgesture.zip?alt=media&token=29e148d3-a5b7-46ca-a124-7f7c1b5bad71>" %}
