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.begin(9600); Serial.println(); Serial.println(F("--------------------------------")); Serial.println(F("SparkFun APDS-9960 - GestureTest")); Serial.println(F("--------------------------------")); // 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 ) { detachInterrupt(0); handleGesture(); isr_flag = 0; attachInterrupt(0, interruptRoutine, FALLING); } } void interruptRoutine() { isr_flag = 1; } void handleGesture() { 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; default: Serial.println("NONE"); } } }
Resources
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?
Hi
In SparkFun_APDS9960.h change #define DEFAULT_GGAIN from GGAIN_4X to GGAIN_2X or GGAIN_1X
Thank you very much, this got it working 🙂
I’m facing the same problem. I have changed 4x to both 2x and 1x . but neither worked. so what to do? kindly respond .
Follow the instructions carefully and use proper Arduino Library and Sensor, you may get desired output.
That’s not the solution to the problem.
Don’t randomly listen to any comment you stumble upon, or you might brick your boards
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?
Had the same problems.
Changed 4x in to 1x and now it works.