APDS-9960 3.3V Hand Gesture Ambient Light RGB Proximity Sensor Module Example Code

0
APDS-9960 3.3V Gesture Sensor Module | RGB & Proximity

 

 

APDS-9960 Gesture, Ambient Light, RGB & Proximity Sensor Module Guide

The APDS-9960 Sensor Module is a versatile I²C sensor capable of detecting hand gestures, measuring ambient light levels, identifying RGB color values, and sensing proximity. This all-in-one module is popular in Arduino, ESP32, Raspberry Pi, robotics, automation, and STEM education projects.

Operating from a 3.3V supply, the APDS-9960 can recognize common gestures such as up, down, left, right, near, and far movements without physical contact. This makes it ideal for touchless controls, smart devices, interactive displays, and automation systems.

In addition to gesture detection, the sensor can measure ambient light intensity, detect proximity to nearby objects, and provide RGB color data for colour recognition applications.

Required Arduino Library

Before uploading code, install the SparkFun APDS9960 Library using the Arduino Library Manager.

Arduino Gesture Detection Example

#include <Wire.h>
#include <SparkFun_APDS9960.h>

SparkFun_APDS9960 apds;

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

  if (apds.init()) {
    Serial.println("APDS-9960 Initialized");
  } else {
    Serial.println("Initialization Failed");
    while(1);
  }

  apds.enableGestureSensor(true);
}

void loop() {

  if (apds.isGestureAvailable()) {

    switch(apds.readGesture()) {

      case DIR_UP:
        Serial.println("UP");
        break;

      case DIR_DOWN:
        Serial.println("DOWN");
        break;

      case DIR_LEFT:
        Serial.println("LEFT");
        break;

      case DIR_RIGHT:
        Serial.println("RIGHT");
        break;

      case DIR_NEAR:
        Serial.println("NEAR");
        break;

      case DIR_FAR:
        Serial.println("FAR");
        break;
    }
  }
}

Typical Wiring

APDS-9960 VIN  -> 3.3V
APDS-9960 GND  -> GND
APDS-9960 SDA  -> Arduino SDA
APDS-9960 SCL  -> Arduino SCL
APDS-9960 INT  -> Optional Interrupt Pin

Supported Features

  • Hand gesture recognition
  • Ambient light sensing
  • RGB colour detection
  • Proximity detection
  • I²C communication interface
  • Low power operation

Common Applications

  • Touchless control systems
  • Smart home automation
  • Interactive displays
  • Robotics projects
  • Colour sorting systems
  • Automatic screen brightness adjustment
  • STEM and educational projects

Important Notes

Most APDS-9960 modules are designed for 3.3V operation. While some breakout boards include voltage regulation and level shifting, always verify the specifications of your particular module before connecting it directly to a 5V microcontroller.

Gesture detection works best when a hand passes within a few centimetres of the sensor. Performance can be affected by strong ambient lighting, reflective surfaces, and mounting position.

Getting the Best Results

For reliable gesture recognition, mount the sensor where it has a clear field of view and avoid placing it behind tinted plastics or glass. Experimenting with sensor placement and gesture speed can significantly improve detection accuracy.

Leave a Reply

Your email address will not be published. Required fields are marked *