Skip to content

setAmbientLight()

Arnd edited this page Dec 11, 2020 · 3 revisions

setAmbientLight([SampleRate],[Averages])

This function sets the tunables for the ambient light sensor (ALS). Two values can be set, the first is the "SampleRate" which is the number of samples collected per second. This ranges from 1 to 10 samples per second with a default value of 2, and is only used when continuous sampling is enabled using the SetAmbientContinuous() function. The second parameter is the number of averages taken per reading, which ranges from 1 to 128 (the internal sample rate setting only uses powers of 2, e.g. 1, 2, 4, ... 128). This setting applies to the normal request-conversion sampling mode as well as to the automated continuous sampling mode linked to above.


Example:

VCNL4010 Sensor();            // Instantiate class    
...    
while(!Sensor.begin());       // loop until initialized
Sensor.setAmbientLight(4,32); // 4/s samples, 32 readings averaged together