Skip to content

getAmbientLight()

Arnd edited this page Dec 11, 2020 · 3 revisions

getAmbientLight()

This function retrieves the most recent ALS (ambient light sensor) reading from the VCNL4010. The library is set up to start a new sampling directly after reading the previous value, which saves microseconds sampling time on each call. When continuous sampling is enabled using the SetAmbientContinuous() function the most recent value is returned while the device continues sampling in the background.


Example:

VCNL4010 Sensor();                                // Instantiate class    
...    
while (!Sensor.begin());                          // Initialize the VCNL4010
uint16_t currentValue = Sensor.getAmbientLight(); // Retrieve most recent value
Serial.print("Ambient light value is ");          // Show message
Serial.println(currentValue);                     // Show value