Phipps Electronics

Order within the next 

FREE SHIPPING OVER $199

50,000+ ORDERS

WORLDWIDE SHIPPING

SSL SECURED

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

Contents

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 Module

The APDS-9960 module has multiple functionalities: measuring ambient light and color (clear, red, green, and blue), 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.

Components

  • 1 x Uno Board (Arduino Compatible)
  • 1 x RGB Motion Direction Identification Infrared Sensor Module – APDS-9960
  • 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

The 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.

SUBSCRIBE FOR NEW POST ALERTS

Subscribe to be the first to know when we publish a new article!
List Subscriptions(Required)

POPULAR POSTS

Scroll to Top