The Adafruit APDS-9960 is a multifunctional sensor that offers digital proximity, ambient light, RGB, and gesture sensing capabilities. This sensor is capable of detecting simple hand gestures, measuring the intensity of ambient light, and identifying colors, making it an ideal choice for a wide range of applications such as gesture-based control systems, automatic screen brightness adjustment, and interactive toys.
Common applications include:
Pin Number | Name | Description |
---|---|---|
1 | VDD | Power supply (2.4V to 3.6V) |
2 | GND | Ground connection |
3 | SDA | I2C Data Line |
4 | SCL | I2C Clock Line |
5 | INT | Interrupt output (active low) |
To use the APDS-9960 sensor in a circuit, connect the VDD pin to a 2.4V to 3.6V power supply, the GND pin to the ground, and the SDA and SCL pins to the I2C data and clock lines, respectively. The INT pin can be connected to a microcontroller's external interrupt input to respond to gesture or proximity events.
#include <Wire.h>
#include <Adafruit_APDS9960.h>
Adafruit_APDS9960 apds;
void setup() {
Serial.begin(9600);
if (!apds.begin()) {
Serial.println("Failed to initialize APDS-9960! Please check your wiring.");
while (1);
}
Serial.println("APDS-9960 initialization complete");
// Enable gesture sensing
if (!apds.enableGestureSensor(true)) {
Serial.println("Gesture sensor is not enabled!");
}
}
void loop() {
// Check if a gesture is available
if (apds.gestureAvailable()) {
switch (apds.readGesture()) {
case APDS9960_DIR_UP:
Serial.println("Detected UP gesture");
break;
case APDS9960_DIR_DOWN:
Serial.println("Detected DOWN gesture");
break;
case APDS9960_DIR_LEFT:
Serial.println("Detected LEFT gesture");
break;
case APDS9960_DIR_RIGHT:
Serial.println("Detected RIGHT gesture");
break;
case APDS9960_DIR_NEAR:
Serial.println("Detected NEAR gesture");
break;
case APDS9960_DIR_FAR:
Serial.println("Detected FAR gesture");
break;
default:
// No gesture detected
break;
}
}
}
Q: Can the APDS-9960 sensor detect gestures in complete darkness? A: Yes, the sensor uses infrared LEDs for gesture detection, which can work in low or no light conditions.
Q: How do I calibrate the sensor for ambient light and color detection? A: Calibration involves reading the sensor values under known lighting conditions and adjusting the readings programmatically to match the known values.
Q: What is the maximum distance for reliable gesture detection? A: The sensor can reliably detect gestures up to approximately 10 cm away, depending on environmental conditions and setup.
Q: Is the APDS-9960 sensor compatible with 5V systems? A: The sensor operates at 2.4V to 3.6V. For 5V systems, level shifters or voltage regulators should be used to ensure compatibility.
For further assistance, consult the Adafruit APDS-9960 datasheet and the Adafruit support forums.