This sensor provides digital ambient light sensing (ALS), IR LED and a complete proximity detection system.
light_proximity.enableIlluminance(true);
light_proximity.enableProximity(true);
upm_delay_us(120000);
while (shouldRun) {
float lux = light_proximity.getAmbient();
cout << "Luminance value is " << lux << endl;
float proximity = light_proximity.getProximity();
cout << "Proximity value is " << proximity << endl;
upm_delay(1);
}
light_proximity.enableProximity(false);
light_proximity.enableIlluminance(false);