Skip to content

APDS9960

Works with

Any CircuitPython board with I2C

What it does

The APDS9960 packs four sensing modes into one chip: gesture detection, proximity detection, RGB color sensing, and ambient light sensing. Gesture detection recognizes swipes in four directions (up, down, left, right) using an array of photodetectors. Proximity detection returns a 0–255 value indicating how close an object is to the sensor face. Color sensing returns raw R, G, B, and clear light values. One important constraint: gesture, proximity, and color modes share internal hardware resources, so only one mode should be active at a time. Switching between modes requires disabling the previous mode first.

Installing the library

Copy the adafruit_apds9960/ folder from the Adafruit CircuitPython Bundle to your board's lib/ folder. Also copy adafruit_bus_device/ if it is not already present.

Quick start — gesture mode

import board
import busio
from adafruit_apds9960.apds9960 import APDS9960

i2c = busio.I2C(board.SCL, board.SDA)
sensor = APDS9960(i2c)
sensor.enable_proximity = True
sensor.enable_gesture = True

while True:
    gesture = sensor.gesture()
    if gesture == 1:
        print("up")
    elif gesture == 2:
        print("down")
    elif gesture == 3:
        print("left")
    elif gesture == 4:
        print("right")

Key things you can do

What you want How to do it
Enable gesture detection sensor.enable_proximity = True; sensor.enable_gesture = True
Read gesture sensor.gesture() → 1=up, 2=down, 3=left, 4=right, 0=none
Enable proximity detection sensor.enable_proximity = True
Read proximity (0-255) sensor.proximity
Enable color/light sensing sensor.enable_color = True
Read color values sensor.color_data(r, g, b, clear) tuple

Reading the official docs

https://docs.circuitpython.org/projects/apds9960/en/latest/

The library is structured as a package — import from adafruit_apds9960.apds9960. Gesture mode requires proximity to be enabled first; the docs note this dependency. If gestures are unreliable, check that nothing is blocking the sensor's field of view within the required operating distance (typically 10–20 cm).

Projects using this library