This circuit interfaces an Arduino UNO with an APDS-9930 Proximity and Ambient Light Sensor. The Arduino UNO reads proximity data from the sensor and prints the values to the Serial Monitor.
Arduino UNO
APDS-9930 Proximity and Ambient Light Sensor
/*
* Arduino Sketch for interfacing with APDS-9930 Proximity and Ambient Light
* Sensor. This code initializes the sensor and reads proximity data, printing
* the values to the Serial Monitor.
*/
#include <Wire.h>
#include <Adafruit_APDS9960.h>
Adafruit_APDS9960 apds;
void setup() {
Serial.begin(9600);
while (!Serial) {
delay(10); // Wait for Serial to be ready
}
Serial.println("APDS-9930 Proximity Sensor Test");
if (!apds.begin()) {
Serial.println("Failed to initialize APDS-9930!");
while (1);
}
Serial.println("APDS-9930 initialized.");
apds.enableProximity(true);
}
void loop() {
uint8_t proximity = apds.readProximity();
Serial.print("Proximity: ");
Serial.println(proximity);
delay(500); // Delay for half a second
}
Libraries Used:
Wire.h
: For I2C communication.Adafruit_APDS9960.h
: For interfacing with the APDS-9930 sensor.Setup Function:
Loop Function: