-
Notifications
You must be signed in to change notification settings - Fork 2
begin()
This function initializes the VCNL4010 device, defaulting to address 0x13 unless another address is specified and sets the default values for several attributes. It will return a boolean "true" or "false" depending on whether it can locate a device on the I2C pins. The optional "I2C_Speed" parameter specifies the I2C bus speed in Herz, it defaults to I2C_STANDARD_MODE (100KHz) but values of I2C_FAST_MODE (400KHz), I2C_FAST_MODE_PLUS_MODE (1MHz) and I2C_HIGH_SPEED_MODE (3.4MHz) are also accepted.
The defaults are as follow:
Type | Value | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Proximity Hertz | 2 | This is a the sampling rate in Hz for the proximity sensor. It can range from 2 to 250 and the values here are interpolated to the following valid internal ones:
|
||||||||||||||||
LED Strength | 20 | The output power of the infrared proximity sensor ranges from 0 (off) to 200 milliamps (max) in steps of 20, the default is 20. | ||||||||||||||||
Ambient light Sample Rate | 2 | The ambient light can be sampled from 2 to 10 times per second. | ||||||||||||||||
Ambient light Averaging Rate | 2 | The ambient light readings are averaged, from 1 to 32 times per actual output reading. | ||||||||||||||||
Proximity frequency | 0 | The proximity sensor frequency uses a square IR signal with the following 4 possible values:
|
||||||||||||||||
Interrupt Settings | false | The device can trigger a "low" signal on an interrupt pin, for a new ambient reading, a new proximity reading, or if a given low/high threshold has been exceeded on either the ambient light or proximity sensor. This is turned off by default. |
VCNL4010 Sensor(); // Instantiate class
...
while (!Sensor.begin()) { // Loop until sensor found
Serial.println("Error, unable to find or identify VCNL4010."); // Show error message
delay(5000); // Wait 5 seconds before retrying
} // of if-then we can't initialize or find the device
Overview
Installation
Class Instantiation
begin()
setProximityHz()
setLEDmA()
setProximityFreq()
setAmbientLight()
setAmbientContinuous()
setProximityContinuous()
setInterrupt()
getAmbientLight()
getProximity()
getInterrupt()
clearInterrupt()
readByte() (advanced)
readWord() (advanced)
writeByte() (advanced)
-none-
CheckDistance.ino
DisplayMeasurements.ino
RegressionTests.ino
WakeOnInterrupt.ino