Skip to content

setAmbientContinuous()

Arnd edited this page Dec 11, 2020 · 3 revisions

setAmbientContinuous([On/Off])

The VCNL4010 defaults to a mode where a measurement for the Ambient (and Proximity) needs to be triggered explicitly by the program before sampling is performed. This function, when called with a parameter value of "true", enables the continuous background measurement mode of the VCNL4010 where readings are automatically performed rather than triggered manually. Setting the value to "false" reverts the system back to normal mode.

This mode is particularly useful when the VCNL4010 is used to trigger interrupts. With this mode set and an alarm threshold for minimum and/or maximum values enabled using the SetInterrupt() function the controlling Arduino can be processing other items asynchronously or even put to sleep while measurements are taking place in the background.


Example:

VCNL4010 Sensor();                 // Instantiate class    
... 
while(!Sensor.begin());            // loop until initialized   
Sensor.setAmbientContinuous(true); // Continuously sample ambient using frequency and averaging settings