APDS-9960 gesture sensor
Light, color, proximity and hand swipes from one little chip, over I2C.
- 6 pins
- In 1 project

The APDS-9960 gesture sensor in brief
What it is, and where it sits on the bench.
The APDS-9960 is Broadcom’s all-in-one optical sensor, usually on the GY-9960 board and also built into the Arduino Nano 33 BLE Sense. Behind its small window sit four photodiodes, one on each side, and an infrared LED. Together they measure ambient light and its red, green and blue parts, how close something is, and which way a hand swipes across it, judged by the order in which the four diodes see the reflection. It is a 3.3 V part on I2C at 0x39. In Mokxi sliders set the room’s light and how near a hand is, arrows swipe a hand over the sensor, and a button steps the light’s color. The model follows the datasheet’s enable bits, so nothing measures until the chip is powered and each engine switched on, along with the color integration and gain, proximity with thresholds, and the 32-set gesture FIFO that the libraries read.
- Family
- Sensors
- Pins
- 6
6 pins
Named as the editor names them, so a wire lands where you expect it.
VCC; leave it open.VCC.VCC.How to read APDS-9960 gestures with an Arduino
VCC goes to the Uno’s 3.3 V pin, not 5 V, and GND to ground; SDA and SCL go to A4 and A5. The board’s pull-ups go to its own 3.3 V supply. In the swipe lamp project an LED on pin 9, through 220 ohms, is the lamp the gestures control.
SparkFun’s library does the decoding. apds.init() checks the chip, enableLightSensor(false) and enableGestureSensor(true) switch on the engines without interrupts, and in the loop isGestureAvailable() and readGesture() return DIR_UP, DIR_DOWN, DIR_LEFT or DIR_RIGHT. The project brightens the lamp on up, dims it on down, and turns it off and on with left and right. Every two seconds it also prints the clear, red, green and blue counts; press the C button on the part to change the light’s color and watch them shift.
On an ESP32 or a Pico, the board’s 3.3 V and default I2C pins suit it directly, with no level concerns.
#include <Wire.h>
#include <SparkFun_APDS9960.h>
SparkFun_APDS9960 apds;
void setup() {
apds.init();
apds.enableLightSensor(false);
apds.enableGestureSensor(true);
}
void loop() {
if (apds.isGestureAvailable()) {
switch (apds.readGesture()) {
case DIR_UP: level = min(level + 64, 255); break;
case DIR_DOWN: level = max(level - 64, 0); break;
case DIR_LEFT: on = false; break;
case DIR_RIGHT: on = true; break;
}
}
}Common APDS-9960 gesture sensor errors and fixes
Questions and answers
What can the APDS-9960 sense?
Four things from one chip: ambient light, red, green and blue light, proximity, and swipes up, down, left and right.
Which library reads the APDS-9960 here?
SparkFun’s, as SparkFun_APDS9960.h, is the one the swipe lamp uses. Adafruit_APDS9960.h works too.
How does the APDS-9960 tell which way a hand moved?
Its four photodiodes face up, down, left and right. A swipe lights the near side first and the far side last, and the library reads that order from the gesture FIFO.
Does the APDS-9960 need the INT pin?
No. The swipe lamp polls with isGestureAvailable(). INT is an open-drain output for sketches that would rather be told; it is low while an enabled interrupt is set.
What is true about the APDS-9960 gesture sensor, here
In its help article’s own words: what the simulation gets right, and where it stops.
Modeled
From the APDS-9960 datasheet:
Nothing until it is powered: no reading lands until PON is set in ENABLE,
and each engine runs only while its own bit is on.
Color: the integration time from ATIME, 2.78 ms a step, the gain from 1x to
64x, the most a channel can count, and the four little-endian words with AVALID.
Proximity scales with its gain and LED drive, with thresholds that raise an interrupt.
Gestures: a 32-set FIFO of up, down, left and right readings, its level, the valid and overflow flags, and the engine that runs while a hand is over it and exits when it leaves. A swipe lights the near side's photodiode first and the far side's last, which is what the libraries look for.
Not modeled
The light is a level in lux and a color, counted at a round 2.5 a lux for each 100 ms at 1x; Broadcom gives each channel's response per microwatt a square centimeter, with spectral curves and infrared leakage this leaves out. Gesture gain, wait time and thresholds hold what is written but any swipe passes, and the interrupts have no persistence filter.
From APDS-9960 gesture sensor, in full.
See the APDS-9960 gesture sensor in a project
One built-in project uses it. It opens in the editor, already wired.
The boards it is shown on
This board has a built-in project with the APDS-9960 gesture sensor in it.
Arduino libraries for the APDS-9960 gesture sensor
Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the APDS-9960 gesture sensor
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.