Continuing our investigation about the APDS-9960 module, the integrated proximity sensor can sense distances up to a few centimeters (~6 centimeters).

In this simple project, 4 LEDs will be turned on via distance thresholds.

Hardware Used

Software Used

  • Arduino IDE

Libraries Used

Since we are using the same module, the Adafruit Library will be enough for this simple mini-project.

Application Description

According to, there are three types of proximity dection systems : sensing metallic objects via eddy currents, recognizing electrical capacity changes in approaching objects, and utilizing magnets and reed switches.

For this particular module, An IR LED emits an infrared radiation (IR light) which bounces off on any nearby object or surface. The proximity distance is measured by the reflected IR light received by a photodiode. If the distance between the object and sensor is near, the reflected IR light intensity will be greater than distances afar. Thus the photodiode voltage increases in proportion to the IR light received, or distance.

Proximity Sensor in Action From (

Since we are using the similar set-up from the gesture sensor, the only changes are the arrangements of pins and its corresponding pin numbers.


Set-up the Hardware

The hardware is pretty straightforward to set-up.



Code Breakdown

This function returns TRUE when the the APDS-9960 is detected. Otherwise it will return FALSE.

As the name implies, it enables the proximity sensor of the module.

This function returns the converted analog signal to discrete digital levels, which ranges from 0 to 255.

This snippet of code compares if the “proximity_data” is greater than the set distance thresholds. If it is greater, then the corresponding LED lights up. Otherwise the LED is turned off.

More library codes/functions are not used but explored below.

The arguments above adjusts the proximity sensor’s gain. To use the arguments, call the function in setup().

where “GAIN” is one of the arguments shown above.

These functions will enable the Proximity Interrupt feature of the module. If enabled, the following functions can be used.


The Gesture sensor can sense proximity and, with a few calibrations, return distance in centimeters or inches. It works by  using a photodiodes to sense the reflected IR light. As such, ambient light (from nearby light sources) can affect the proximity threshold.



Tags : APDS-9960APDS-9960 ProximityarduinoGesture Sensorlight sensorProximityProximity Sensor

Leave a Response

Warning: Cannot assign an empty string to a string offset in /home/createl1/public_html/community/wp-includes/class.wp-scripts.php on line 454

Warning: Cannot assign an empty string to a string offset in /home/createl1/public_html/community/wp-includes/class.wp-scripts.php on line 454