APDS9960 Gesture, RGB and Proximity sensor for Arduino
In this tutorial, we will explore how to use the APDS9960 sensor module, which combines gesture detection, RGB color sensing, and proximity sensing capabilities. This versatile sensor can detect movements in various directions and can be integrated into projects for controlling motors, lights, or other devices based on hand gestures. By the end of this tutorial, you will understand how to wire the sensor and implement basic gesture detection in your Arduino projects.

The APDS9960 module is compact and requires minimal wiring, making it an excellent choice for interactive projects. We will be using the Arduino IDE to program the sensor and display the detected gestures on the serial monitor. For a visual guide, refer to the video at (in video at 00:00).
Hardware Explained
The key component of this project is the APDS9960 sensor module. This module is capable of detecting gestures such as swipe left, swipe right, swipe up, and swipe down. It also measures RGB color values and proximity to nearby objects. The sensor communicates with the Arduino using I2C, which simplifies the wiring and coding process.
The APDS9960 contains multiple internal sensors: a gesture sensor, an RGB color sensor, and an ambient light sensor. The gesture sensor uses an infrared LED and photodetector to detect hand movements, while the RGB sensor measures red, green, and blue light intensities to identify colors. The proximity sensor determines how close an object is to the sensor, which can be useful in various applications.
Datasheet Details
| Manufacturer | Avago Technologies |
|---|---|
| Part number | APDS-9960 |
| Logic/IO voltage | 1.8 V to 3.6 V |
| Supply voltage | 3.3 V |
| Output current (per channel) | 20 mA max |
| Peak current (per channel) | 100 mA |
| PWM frequency guidance | Not applicable |
| Input logic thresholds | 0.3 V (low), 0.7 V (high) |
| Voltage drop / RDS(on) / saturation | 0.5 V max |
| Thermal limits | -40 to 85 °C |
| Package | 6-pin LGA |
| Notes / variants | None |
- Always power the APDS9960 with 3.3V; higher voltages can damage the sensor.
- Ensure proper pull-up resistors on the I2C lines if connecting multiple devices.
- Keep the sensor away from direct sunlight to avoid interference.
- Use a decoupling capacitor close to the power pins for stability.
- Be aware of the sensing range for proximity detection (typically around 20 cm).
Wiring Instructions

To wire the APDS9960 sensor module to your Arduino, follow these steps:
- Connect the
VCCpin of the APDS9960 to the 3.3V pin on the Arduino. - Connect the
GNDpin to one of the GND pins on the Arduino. - Connect the
SDApin to the Arduino'sA4pin (I2C data line). - Connect the
SCLpin to the Arduino'sA5pin (I2C clock line). - Connect the
INTpin to digital pin2on the Arduino for interrupt handling.
Note that if you are using a different Arduino model, the SDA and SCL pins may vary (e.g., on an Arduino Mega, use SDA on pin 20 and SCL on pin 21). Make sure to check the specific pin mappings for your board. For different configurations, refer to the video at (in video at 02:30).
Code Examples & Walkthrough
In the setup function, we initialize the serial communication and the APDS9960 sensor. The interrupt pin is set up to listen for gesture events. Here's a snippet of the setup code:
void setup() {
pinMode(APDS9960_INT, INPUT);
Serial.begin(9600);
Serial.println(F("APDS-9960 initialization..."));
if (apds.init()) {
Serial.println(F("Initialization complete"));
} else {
Serial.println(F("Initialization failed"));
}
}
This code sets up the necessary configurations to ensure that the sensor is ready for use and provides feedback in the serial monitor.
Next, we define how to handle the gestures detected by the sensor. The handleGesture function uses a switch statement to determine the direction of the gesture. Here’s a focused excerpt:
void handleGesture() {
if (apds.isGestureAvailable()) {
switch (apds.readGesture()) {
case DIR_UP:
Serial.println("UP");
break;
case DIR_DOWN:
Serial.println("DOWN");
break;
// Additional cases for left, right, near, and far
}
}
}
This function checks if a gesture is available and reads its direction, printing the result to the serial monitor for feedback. Make sure to refer to the full code loaded below the article for complete implementation details.
Demonstration / What to Expect
When you run the program, you should see the detected gestures printed on the serial monitor as you move your hand in different directions. For instance, swiping up should display "UP," while swiping down shows "DOWN." Make sure to hold your hand steady for a second when performing near and far gestures (in video at 10:00).
Be cautious with the sensor's proximity detection; if you move your hand too quickly or too far from the sensor, it may not register the gesture accurately. This is a common issue that can affect performance.
Video Timestamps
- 00:00 - Introduction to the APDS9960 sensor
- 02:30 - Wiring instructions
- 05:15 - Code explanations
- 10:00 - Demonstration of gesture recognition
Things you might need
-
Amazon
-
AliExpressPurchase AM2302 or DHT11 or DHT22 sensor from AliExpresss.click.aliexpress.com
Resources & references
-
ExternalAdafruit APDS9960 library (from GitHub)github.com
Files📁
Fritzing File
-
APDS 9960 rgb and gesture sensor
application/zip0.01 MB
Other files
-
APDS9960 Gesture Library from RobojaxThis library used for Gesture Sensor APDS9960 to detect movement of your hand and detect present color.
robojax-gesture-APDS9960-Library.zip