Arduino Gesture Sensor APDS 9960

Last Updated on March 28, 2024


Gesture and Ambient light sensor APDS-9960 from Avago Technologies helps us to make simple and robust Gesture control project. The sensor utilizes four directional photo diodes to sense reflected IR light to convert physical motion Information to a Digital information (simply gesture info).

The architecture of the gesture engine features automatic activation (based on Proximity engine results), ambient light subtraction, cross-talk cancelation, dual 8-bit data converters, power saving inter-conversion delay, 32-dataset FIFO, and interrupt-driven I2C-bus communication. The gesture engine accommodates a wide range of mobile device gesturing requirements  simple UP-DOWN-RIGHT-LEFT gestures or more complex gestures can be accurately sensed. Power consumption and noise are minimized with adjustable IR LED timing. (credit Avago Technologies).

Application Note

With this APDS 9960 sensor we can make interaction to Arduino, Microcontroller, Computer, robot etc.. with simple gesture swipe of your hand.

Sensor Breakout board Pinout


Arduino-APDS 9960 Hookup


Arduino Code

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

// Pins
#define APDS9960_INT    2 // Needs to be an interrupt pin

// Constants

// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;

void setup() {

  // Initialize Serial port
  Serial.println(F("SparkFun APDS-9960 - GestureTest"));

  // Initialize interrupt service routine
  attachInterrupt(0, interruptRoutine, FALLING);

  // Initialize APDS-9960 (configure I2C and initial values)
  if ( apds.init() ) {
    Serial.println(F("APDS-9960 initialization complete"));
  } else {
    Serial.println(F("Something went wrong during APDS-9960 init!"));

  // Start running the APDS-9960 gesture sensor engine
  if ( apds.enableGestureSensor(true) ) {
    Serial.println(F("Gesture sensor is now running"));
  } else {
    Serial.println(F("Something went wrong during gesture sensor init!"));

void loop() {
  if( isr_flag == 1 ) {
    isr_flag = 0;
    attachInterrupt(0, interruptRoutine, FALLING);

void interruptRoutine() {
  isr_flag = 1;

void handleGesture() {
    if ( apds.isGestureAvailable() ) {
    switch ( apds.readGesture() ) {
      case DIR_UP:
      case DIR_DOWN:
      case DIR_LEFT:
      case DIR_RIGHT:
      case DIR_NEAR:
      case DIR_FAR:


APDS 9960 – Arduino Library

APDS 9960 – Datasheet 

8 thoughts on “Arduino Gesture Sensor APDS 9960

  1. Hi

    i having issue with it and would like to seek your advice. The proximity and color sensor are working but not the gesture detection. How can i know if it is working or malfunction for the 9960 sensor? i had tried to recompile the Sparkfun ADPS 9960 library by inserting test code to check the output which i noted that the program stop at the “readgesture” and a value of 255 is returned. i had also tried verbose the debug statement and noted that the readings of the FIFO numbers do change (from random numbers to 255) when i put my hand near and far from the sensor. I also experiment changing the gain of the gesture sensor but no effect. Please advise what more can i do to fix it?

    1. In fact changing it to 1x works perfect for me. When it was on default (4x) – I didn’t get ANY output, with 1x it’s quite reliable — still I don’t know what this setting does, maybe somebody could elaborate?

Leave a Reply

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