Skip to content

DisplayMeasurements.ino

Arnd edited this page Dec 25, 2020 · 7 revisions

Arduino sketch to read and display measurements from the Vishay VCNL4010 sensor.

Compatibility

No special processor-dependent calls are used and thus this sketch should run on any of the Arduino systems. The serial port speed defaults to 115200 baud.

Function

The VCNL4010 is initialised in the setup() method with the following explicit values:

  • The LED proximity sensor is boosted to 200mA for greater sensitivity and distance
  • Ambient light sensor set to sample 2 times per second with 128 averages per reading
  • Proximity sensor set to sample 128 times per second

After initialisation the program loops infinitely. It displays the time in milliseconds, the ambient light reading and the proximity reading when either of the sensor readings changes by more than 15% from the last reading.