Phipps Electronics

FREE SHIPPING OVER $199

30,000+ ORDERS

WORLDWIDE SHIPPING

SSL SECURED

Using The RGB Motion Direction IR Sensor APDS-9960 with Arduino

INTRODUCTION:

In this tutorial, we will learn about the APDS-9960 module, how it works and we will build a simple project using the APDS-9960 and an Arduino.

THE RGB MOTION DIRECTION IDENTIFICATION INFRARED SENSOR MODULE – APDS-9960:

The APDS-9960 module has multiple functionalities; ambient light and color (as clear, red, green, and blue) measuring, proximity detection, and gesture sensing.

RGB Motion Direction IR Sensor GY-9960 front view
Figure 1: RGB MOTION DIRECTION IDENTIFICATION INFRARED SENSOR MODULE – APDS-9960

PIN OUT:

The APDS-9960 has six pins.

PinDescription
VLOptional power to the IR LED if PS jumper is disconnected. Must be 3.0 - 4.5V
GNDConnect to Ground
VCCUsed to power the APDS-9960 sensor. Must be 2.4 - 3.6V
SDAIIC data
SCLIIC clock
INTExternal interrupt pin. Active LOW on interrupt event

HOW DOES IT WORK?

The APDS-9960 has a built-in multifunctional infrared sensor and uses IIC communication protocol to communicate with the microcontroller.

PROJECT – ARDUINO GESTURE MONITOR

This project will demonstrate how the APDS-9960 module shows the hand gesture performed in the serial monitor.

PROJECT COMPONENTS REQUIRED:

  • Arduino Uno Board (1 pc.)
  • RGB Motion Direction Identification Infrared Sensor Module – APDS-9960 (1 pc.)
  • Jumper Wires

WIRING DIAGRAM:

The APDS-9960 module pins are connected to the Arduino Uno board as follows:

Module PinUNO Board Pin
GNDGND
VCCVCC
SDAA4
SCLA5
INT2
GNDGND
VCCVCC

RGB Motion Direction IR Sensor APDS-9960 with Arduino wiring diagram

CODE:

Download the library for the module first before proceeding. The library is available here; Arduino APDS9960 Library

Once the library is installed, the program code can be uploaded. For this project the GestureSensor.ino program code will be used and can be found in the examples folder.

/*
  APDS-9960 - Gesture Sensor

  This example reads gesture data from the on-board APDS-9960 sensor of the
  Nano 33 BLE Sense and prints any detected gestures to the Serial Monitor.

  Gesture directions are as follows:
  - UP:    from USB connector towards antenna
  - DOWN:  from antenna towards USB connector
  - LEFT:  from analog pins side towards digital pins side
  - RIGHT: from digital pins side towards analog pins side

  The circuit:
  - Arduino Nano 33 BLE Sense

  This example code is in the public domain.
*/

#include <Arduino_APDS9960.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);

  if (!APDS.begin()) {
    Serial.println("Error initializing APDS-9960 sensor!");
  }

  // for setGestureSensitivity(..) a value between 1 and 100 is required.
  // Higher values make the gesture recognition more sensitive but less accurate
  // (a wrong gesture may be detected). Lower values makes the gesture recognition
  // more accurate but less sensitive (some gestures may be missed).
  // Default is 80
  //APDS.setGestureSensitivity(80);

  Serial.println("Detecting gestures ...");
}
void loop() {
  if (APDS.gestureAvailable()) {
    // a gesture was detected, read and print to Serial Monitor
    int gesture = APDS.readGesture();

    switch (gesture) {
      case GESTURE_UP:
        Serial.println("Detected UP gesture");
        break;

      case GESTURE_DOWN:
        Serial.println("Detected DOWN gesture");
        break;

      case GESTURE_LEFT:
        Serial.println("Detected LEFT gesture");
        break;

      case GESTURE_RIGHT:
        Serial.println("Detected RIGHT gesture");
        break;

      default:
        // ignore
        break;
    }
  }
}


PROJECT TEST:

Wire the components to the Arduino as demonstrated in the wiring diagram. Connect the Arduino to a PC and upload the program. Open the Serial Monitor in the Arduino IDE and the hand gesture performed in front of the sensor will be displayed.




Scroll to Top