Skip to content

getProximity()

Arnd edited this page Jan 1, 2017 · 3 revisions

getProximity()

This function retrieves the most recent proximity 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 SetProximityContinuous() 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.getProximity(); // Retrieve most recent value
Serial.print("Proximity sensor value is ");    // Show message
Serial.println(currentValue);                  // Show value

Clone this wiki locally