Arduino UNO Proximity and Ambient Light Sensor with APDS-9930
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
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.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
APDS-9930 Proximity and Ambient Light Sensor
- Description: A sensor that provides digital ambient light sensing (ALS), IR LED and a complete proximity detection system.
- Pins: INT (not used), SDA, SCL, VCC (3.3V), GND, VL (not used)
Wiring Details
Arduino UNO
- 3.3V: Connected to VCC (3.3V) of the APDS-9930 Proximity and Ambient Light Sensor
- GND: Connected to GND of the APDS-9930 Proximity and Ambient Light Sensor
- SCL: Connected to SCL of the APDS-9930 Proximity and Ambient Light Sensor
- SDA: Connected to SDA of the APDS-9930 Proximity and Ambient Light Sensor
APDS-9930 Proximity and Ambient Light Sensor
- VCC (3.3V): Connected to 3.3V of the Arduino UNO
- GND: Connected to GND of the Arduino UNO
- SCL: Connected to SCL of the Arduino UNO
- SDA: Connected to SDA of the Arduino UNO
Code Documentation
/*
* 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:
- Initializes the Serial communication at 9600 baud rate.
- Waits for the Serial to be ready.
- Initializes the APDS-9930 sensor and enables proximity sensing.
Loop Function:
- Reads the proximity data from the sensor.
- Prints the proximity data to the Serial Monitor.
- Delays for half a second before the next reading.