The APDS-9960 is a versatile sensor that offers ambient light and color measuring, proximity detection, and gesture sensing. It is commonly used in mobile devices for screen brightness adjustment based on ambient light conditions, color matching in printing services, and intuitive user interfaces through gesture control. This sensor is also popular among hobbyists and makers for creating interactive projects with Arduino and other microcontroller platforms.
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 |
6 | VL | Optional IR LED power supply for proximity sensor |
To use the APDS-9960 with a microcontroller like the Arduino UNO, follow these steps:
#include <Wire.h>
#include <SparkFun_APDS9960.h>
// Instantiate APDS9960 object
SparkFun_APDS9960 apds = SparkFun_APDS9960();
void setup() {
Serial.begin(9600);
Wire.begin();
// Initialize APDS-9960 (configure I2C and initial values)
if (apds.init()) {
Serial.println("APDS-9960 initialization complete");
} else {
Serial.println("Something went wrong during APDS-9960 init!");
}
// Start running the APDS-9960 gesture sensor engine
if (apds.enableGestureSensor(true)) {
Serial.println("Gesture sensor is now running");
} else {
Serial.println("Something went wrong during gesture sensor init!");
}
}
void loop() {
if (apds.isGestureAvailable()) {
// If a gesture is detected, read it
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");
}
}
}
Q: Can the APDS-9960 sensor detect gestures in complete darkness? A: Yes, the sensor can detect gestures in the dark as it uses an IR LED for gesture detection.
Q: How can I extend the range of the proximity sensor? A: The range can be extended by increasing the IR LED drive strength, but this will also increase the power consumption.
Q: Is it possible to use multiple APDS-9960 sensors on the same I2C bus? A: No, the APDS-9960 does not have a selectable I2C address, so you cannot use multiple sensors on the same bus without additional hardware, such as an I2C multiplexer.