Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use APDS-9960 RGB and Gesture Sensor: Examples, Pinouts, and Specs

Image of APDS-9960 RGB and Gesture SensorDesign with APDS-9960 RGB and Gesture Sensor in Cirkit Designer

Introduction

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.

Explore Projects Built with APDS-9960 RGB and Gesture Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino Nano-Controlled Lighting System with Gesture and Sound Interaction: A project utilizing APDS-9960 RGB and Gesture Sensor in a practical application
Arduino Nano-Controlled Lighting System with Gesture and Sound Interaction

This circuit features an Arduino Nano microcontroller interfaced with an APDS-9960 RGB and Gesture Sensor for color and gesture detection, and a KY-038 microphone module for sound detection. The Arduino controls a 4-channel relay module, which in turn switches four AC bulbs on and off. The 12V power supply is used to power the relay module, and the bulbs are connected to the normally open (N.O.) contacts of the relays, allowing the Arduino to control the lighting based on sensor inputs.

Open Project in Cirkit Designer
Image of Gesture and Sound Controlled Relay Switching with Arduino Nano: A project utilizing APDS-9960 RGB and Gesture Sensor in a practical application
Gesture and Sound Controlled Relay Switching with Arduino Nano

This circuit features an Arduino Nano microcontroller interfaced with an APDS-9960 RGB and Gesture Sensor for gesture detection and a KY-038 sound sensor for clap detection. It controls a 4-channel relay module to toggle power to connected loads, such as bulbs and fans, based on gesture and clap inputs. The code provided enables gesture recognition and clap detection to toggle the state of the relays, which in turn control the power to the loads.

Open Project in Cirkit Designer

Technical Specifications

Key Technical Details

Pin Configuration and Descriptions

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

Usage Instructions

Integration with a Circuit

To use the APDS-9960 with a microcontroller like the Arduino UNO, follow these steps:

  1. Connect VDD to the 3.3V output on the Arduino.
  2. Connect GND to a ground pin on the Arduino.
  3. Connect SDA and SCL to the corresponding I2C pins on the Arduino (A4 and A5 on the UNO).
  4. The INT pin can be connected to any digital input pin if interrupt functionality is required.
  5. If using the proximity sensor, connect VL to a power source appropriate for the IR LED being used.

Important Considerations and Best Practices

Example Code for Arduino UNO

#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");
    }
  }
}

Troubleshooting and FAQs

Common Issues

Solutions and Tips for Troubleshooting

FAQs

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.